using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.ItemCategory; using MMDAL.DTO.ItemCategory; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.ItemCategory { public class SaveItemCategory : BaseEndpoint> { private readonly IItemCategoryBLL _ItemCategoryBLL; public SaveItemCategory(IItemCategoryBLL ItemCategoryBLL) { _ItemCategoryBLL = ItemCategoryBLL; } public override void Configure() { Post("/ItemCategory/SaveItemCategory"); AllowAnonymous(); } public record SaveItemCategoryParameters( [property: FromHeader] string Login, [property: FromBody] ItemCategoryDTO ItemCategoryDTO ); protected override async Task> ExecuteAsync(SaveItemCategoryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ItemCategoryBLL.SaveItemCategory(req.ItemCategoryDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }