Esempio n. 1
0
        public async Task <IActionResult> RegisterPayment([FromBody] RegisterPaymentCommandRequest commandRequest)
        {
            var commandResponse = await mediator.Send(commandRequest);

            switch (commandResponse.Status)
            {
            case true: return(Ok(commandResponse));

            case false: return(BadRequest(commandResponse));
            }
        }
Esempio n. 2
0
 public async Task RegisterPaymentAsync(RegisterPaymentCommandRequest commandRequest)
 {
     await paymentsControlDataContext
     .connection
     .ExecuteAsync("spRegisterPayment",
                   new
     {
         commandRequest.Id,
         commandRequest.EmployeeId,
         commandRequest.SalaryId,
         commandRequest.PaymentDate
     }, commandType : CommandType.StoredProcedure);
 }
Esempio n. 3
0
        public async Task <HandlerResultEntity <RegisterPaymentCommandResponse> > Handle(RegisterPaymentCommandRequest commandRequest, CancellationToken cancellationToken)
        {
            var validationResult = await validator.ValidateAsync(commandRequest, cancellationToken);

            if (validationResult.IsValid)
            {
                if (await employeeRepository.VerifyEmployeeExistsByIdAsync(commandRequest.EmployeeId))
                {
                    if (await salaryRepository.VerifySalaryExistsById(commandRequest.SalaryId))
                    {
                        await paymentRepository.RegisterPaymentAsync(commandRequest);

                        var commandResponse = new RegisterPaymentCommandResponse(commandRequest.Id);

                        return(new HandlerResultEntity <RegisterPaymentCommandResponse>(true, string.Empty, commandResponse));
                    }
                    else
                    {
                        return(new HandlerResultEntity <RegisterPaymentCommandResponse>(false, "salary id doenst exists", null));
                    }
                }
                else
                {
                    return(new HandlerResultEntity <RegisterPaymentCommandResponse>(false, "employee id doenst exists", null));
                }
            }
            else
            {
                return(new HandlerResultEntity <RegisterPaymentCommandResponse>(false, ValidationResultErrorMessage.Format(validationResult), null));
            }
        }