Untitled
Anonymous
plain_text
01/08/2024 4:46 AM
904 B
10
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