using FastEndpoints; using FrameworkBLL.Port; using FrameworkDAL.DTO.Port; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Port { public class SavePort : BaseEndpoint> { private readonly IPortBLL _PortBLL; public SavePort(IPortBLL PortBLL) { _PortBLL = PortBLL; } public override void Configure() { Post("/Port/SavePort"); AllowAnonymous(); } public record SavePortParameters( [property: FromHeader] string Login, [property: FromBody] PortDTO PortDTO ); protected override async Task> ExecuteAsync(SavePortParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PortBLL.SavePort(req.PortDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }