Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
676 B
0
Indexable
Never
// 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();
    }
}
Leave a Comment