30 lines
787 B
C#
30 lines
787 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Emergence.models;
|
|
using Emergence.services.Interface;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Emergence.api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class TenantController : ControllerBase
|
|
{
|
|
private readonly ITenantService _tenantService;
|
|
public TenantController(ITenantService tenantService)
|
|
{
|
|
_tenantService = tenantService;
|
|
}
|
|
|
|
[HttpGet(Name = "GetTenants")]
|
|
public async Task<Results<Ok<IEnumerable<TenantModel>>, NotFound>> Get()
|
|
{
|
|
var tenants = await _tenantService.GetAllAsync();
|
|
if (tenants is null)
|
|
{
|
|
return TypedResults.NotFound();
|
|
}
|
|
return TypedResults.Ok(tenants);
|
|
}
|
|
}
|