using FastEndpoints; using GB5Shared.DTO.Framework.Logging; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Declaration; using PayRollDAL.DTO.Declaration; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Declaration { public class DeclarationBulkUpdate : BaseEndpoint> { private readonly IDeclarationBLL _DeclarationBLL; public DeclarationBulkUpdate(IDeclarationBLL IDeclarationBLL) { _DeclarationBLL = IDeclarationBLL; } public override void Configure() { Post("/Declaration/DeclarationBulkUpdate"); AllowAnonymous(); } public record DeclarationBulkUpdateParameters( [property: FromHeader] string Login, [property: FromBody] List DeclarationDTO ); protected override async Task> ExecuteAsync(DeclarationBulkUpdateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var RESULT = await _DeclarationBLL.DeclarationBulkUpdate(req.DeclarationDTO, LoginDTO!); if (RESULT) { return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( "Details Updated Successfully", CacheKeyLevel.USER_LEVEL, LoginDTO ); } return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( "No Records Updated", CacheKeyLevel.USER_LEVEL, LoginDTO ); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }