Untitled

 avatar
unknown
plain_text
a year ago
676 B
2
Indexable
// Service
public interface IGreetingService
{
    string GetGreetingMessage();
}

public class GreetingService : IGreetingService
{
    public string GetGreetingMessage()
    {
        return "Hello from the GreetingService!";
    }
}

// Controller
[Route("api/[controller]")]
[ApiController]
public class GreetingController : ControllerBase
{
    private readonly IGreetingService _greetingService;

    public GreetingController(IGreetingService greetingService)
    {
        _greetingService = greetingService;
    }

    [HttpGet]
    public ActionResult<string> Get()
    {
        return _greetingService.GetGreetingMessage();
    }
}
Editor is loading...
Leave a Comment