Replace api with controller instead of minimalapi
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Emergence.models;
|
||||
using Emergence.services.Interface;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
|
||||
namespace Emergence.api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]", Name = "Tenant", Order = 1)]
|
||||
public class TenantController : ControllerBase
|
||||
{
|
||||
private readonly ITenantService _tenantService;
|
||||
public TenantController(ITenantService tenantService)
|
||||
{
|
||||
_tenantService = tenantService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetTenants"), ProducesResponseType(StatusCodes.Status200OK), ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<Results<Ok<IList<TenantModel>>, NotFound>> GetAsync()
|
||||
{
|
||||
var tenants = await _tenantService.GetAllAsync();
|
||||
return tenants is IList<TenantModel> result ? TypedResults.Ok(result) : TypedResults.NotFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user