using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Item; using MMDAL.DTO.Item; using MMSL.EndPoints.Item; using static GB5Shared.GB5Constant.Constant; using static MMSL.EndPoints.ItemGroup.SaveItemGroup; namespace MMSL.EndPoints.Item { public class SaveItem : BaseEndpoint> { private readonly IItemBLL _ItemBLL; public SaveItem(IItemBLL ItemBLL) { _ItemBLL = ItemBLL; } public override void Configure() { Post("/Item/SaveItem"); AllowAnonymous(); } public record SaveItemParameters( [property: FromHeader] string Login, [property: FromBody] ItemDTO ItemDTO ); protected override async Task> ExecuteAsync(SaveItemParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ItemBLL.SaveItem(req.ItemDTO, 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); } } } }