using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Authorization; using MMBLL.ItemBrand; using MMDAL.DTO.ItemBrand; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.ItemBrand { public class SaveItemBrand: BaseEndpoint { private readonly IItemBrandBLL _ItemBrandBLL; public SaveItemBrand(IItemBrandBLL itemBrandBLL) { _ItemBrandBLL = itemBrandBLL; } public override void Configure() { Post("/ItemBrand/SaveItemBrand"); AllowAnonymous(); } public record SaveItemBrandParameters( [property: FromBody] ItemBrandDTO itemBrandDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveItemBrandParameters Parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ItemBrandBLL.SaveItemBrand(Parameters.itemBrandDTO, 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); } } } }