using Emergence.api.Interfaces; using Emergence.models; using Emergence.services.Interface; using Microsoft.AspNetCore.Http.HttpResults; namespace Emergence.api.Endpoints; public class UserEndpoints : IEndpoint { private readonly IUserService _userService; public UserEndpoints(IUserService userService) { _userService = userService; } public void MapEndPoint(IEndpointRouteBuilder app) { var endpoints = app.MapGroup("/users") .WithTags("User Items"); endpoints.MapGet("/", GetAll).Produces>(StatusCodes.Status200OK).Produces(StatusCodes.Status404NotFound).WithName("Get All Users"); endpoints.MapGet("/{id}", GetById).Produces(StatusCodes.Status200OK).Produces(StatusCodes.Status404NotFound).WithName("Get User By Id"); } public async Task>, NotFound>> GetAll() => await _userService.GetAllAsync() is List result ? TypedResults.Ok(result) : TypedResults.NotFound(); public async Task, NotFound>> GetById(int id) => await _userService.GetByIdAsync(id) is UserModel result ? TypedResults.Ok(result) : TypedResults.NotFound(); }