using FastEndpoints; using FrameworkBLL.ECMRights; using FrameworkDAL.DTO.ECMRights; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ECMRights { public class SaveECMRights : BaseEndpoint { private readonly IECMRightsBLL _ecmRightsBLL; public SaveECMRights(IECMRightsBLL ecmRightsBLL) { _ecmRightsBLL = ecmRightsBLL; } public override void Configure() { Post("/ECMRights/SaveECMRights"); AllowAnonymous(); } public record SaveECMRightsParameters( [property: FromBody] ECMRightsDTO ECMRightsDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveECMRightsParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ecmRightsBLL.SaveECMRights(parameters.ECMRightsDTO, 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 ); } } } }