Untitled
unknown
plain_text
2 years ago
676 B
5
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