using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using PayRollBLL.PayProcess; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.Controllers { [ApiController] [Route("PayProcess")] public class PayProcessController : ControllerBase { private readonly IPayProcessBLL _IPayProcessBLL; public PayProcessController(IPayProcessBLL IPayProcessBLL) { _IPayProcessBLL = IPayProcessBLL; } [HttpPost("GetPaySlipReport")] [AllowAnonymous] public async Task GetPaySlipReport( [FromQuery] int FirstNumber, [FromQuery] int MaxResult, [FromBody] CriteriaDTO CriteriaDTO, [FromQuery] bool Count, [FromQuery] int Type) { try { LoginDTO Login = new LoginDTO(); if (Request.Headers.TryGetValue("Login", out var loginHeader)) { Login = JsonConvert.DeserializeObject(loginHeader!)!; } var result = await _IPayProcessBLL.GetPaySlipReport( FirstNumber, MaxResult, CriteriaDTO, Login, Count, Type ); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, Login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, null!, ex.Message, 500); } } } }