Files
Emergence/Emergence.api/Controllers/TenantController.cs
T

25 lines
847 B
C#

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();
}
}