Replace api with controller instead of minimalapi

This commit is contained in:
2026-04-01 11:11:19 +10:30
parent f26ff6e04a
commit 5407c7db55
17 changed files with 98 additions and 147 deletions
@@ -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();
}
}