diff --git a/Emergence.api/Controllers/TenantController.cs b/Emergence.api/Controllers/TenantController.cs index 07f2504..acc3435 100644 --- a/Emergence.api/Controllers/TenantController.cs +++ b/Emergence.api/Controllers/TenantController.cs @@ -2,11 +2,12 @@ using Emergence.models; using Emergence.services.Interface; using Microsoft.AspNetCore.Http.HttpResults; +using System.Text.Json.Serialization; namespace Emergence.api.Controllers; [ApiController] -[Route("[controller]", Name = "Tenant", Order = 1)] +[Route("[controller]")] public class TenantController : ControllerBase { private readonly ITenantService _tenantService; @@ -15,10 +16,14 @@ public class TenantController : ControllerBase _tenantService = tenantService; } - [HttpGet(Name = "GetTenants"), ProducesResponseType(StatusCodes.Status200OK), ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task>, NotFound>> GetAsync() + [HttpGet(Name = "GetTenants")] + public async Task>, NotFound>> Get() { var tenants = await _tenantService.GetAllAsync(); - return tenants is IList result ? TypedResults.Ok(result) : TypedResults.NotFound(); + if (tenants is null) + { + return TypedResults.NotFound(); + } + return TypedResults.Ok(tenants); } } diff --git a/Emergence.api/Program.cs b/Emergence.api/Program.cs index 6438d55..f480467 100644 --- a/Emergence.api/Program.cs +++ b/Emergence.api/Program.cs @@ -1,4 +1,5 @@ using Emergence.services.Extensions; +using Scalar.AspNetCore; var builder = WebApplication.CreateBuilder(args); @@ -15,6 +16,7 @@ var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.MapOpenApi(); + app.MapScalarApiReference(); } app.UseHttpsRedirection(); diff --git a/Emergence.models/TenantModel.cs b/Emergence.models/TenantModel.cs index e3c9da5..e8ef930 100644 --- a/Emergence.models/TenantModel.cs +++ b/Emergence.models/TenantModel.cs @@ -2,13 +2,12 @@ using System.Collections.Generic; using System.Text; -namespace Emergence.models +namespace Emergence.models; + +public class TenantModel { - public class TenantModel - { - public Guid Id = new Guid(); - public string TenantCode = string.Empty; - public string CompanyName = string.Empty; - public bool IsInactive = false; - } + public Guid Id { get; set; } + public string TenantCode { get; set; } + public string CompanyName { get; set; } + public bool IsInactive { get; set; } } diff --git a/Emergence.services/Extensions/ServiceBuilderExtension.cs b/Emergence.services/Extensions/ServiceBuilderExtension.cs index ab39bde..2bab7eb 100644 --- a/Emergence.services/Extensions/ServiceBuilderExtension.cs +++ b/Emergence.services/Extensions/ServiceBuilderExtension.cs @@ -11,7 +11,6 @@ namespace Emergence.services.Extensions { public static IServiceCollection AddEmergenceServices(this IServiceCollection services) { - services = services.AddTransient(); services = services.AddTransient(); return services; diff --git a/Emergence.services/Interface/IService.cs b/Emergence.services/Interface/IService.cs index 6b36ff4..dc08a5a 100644 --- a/Emergence.services/Interface/IService.cs +++ b/Emergence.services/Interface/IService.cs @@ -6,7 +6,7 @@ namespace Emergence.services.Interface { public interface IService where T : class { - public Task> GetAllAsync(); + public Task> GetAllAsync(); public Task GetByIdAsync(I id); } } diff --git a/Emergence.services/Services/TenantService.cs b/Emergence.services/Services/TenantService.cs index 47e6e42..a56adc6 100644 --- a/Emergence.services/Services/TenantService.cs +++ b/Emergence.services/Services/TenantService.cs @@ -9,13 +9,13 @@ namespace Emergence.services.Services; public class TenantService : ITenantService { private List testList = [ - new TenantModel {TenantCode = "FJP", CompanyName ="Fred J Potter" }, - new TenantModel {TenantCode = "JAZZ", CompanyName ="Jazzbond" }, - new TenantModel {TenantCode = "TDT", CompanyName ="The Digital Tailor" }, - new TenantModel {TenantCode = "HBAS", CompanyName ="Hicks Building and Asbestos Services" }, + new TenantModel {Id = Guid.NewGuid(), TenantCode = "FJP", CompanyName = "Fred J Potter", IsInactive = false }, + new TenantModel {Id = Guid.NewGuid(), TenantCode = "JAZZ", CompanyName = "Jazzbond", IsInactive = false }, + new TenantModel {Id = Guid.NewGuid(), TenantCode = "TDT", CompanyName = "The Digital Tailor", IsInactive = false }, + new TenantModel {Id = Guid.NewGuid(), TenantCode = "HBAS", CompanyName = "Hicks Building and Asbestos Services", IsInactive = false }, ]; - public async Task> GetAllAsync() + public async Task> GetAllAsync() { return testList; }