Exemplo n.º 1
0
        public async Task <IActionResult> UpdateSalary([FromBody] UpdateSalaryCommandRequest commandRequest)
        {
            var commandResponse = await mediator.Send(commandRequest);

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

            case false: return(BadRequest(commandResponse));
            }
        }
Exemplo n.º 2
0
 public async Task UpdateSalaryAsync(UpdateSalaryCommandRequest commandRequest)
 {
     await paymentsControlDataContext
     .connection
     .ExecuteAsync("spUpdateSalary",
                   new
     {
         commandRequest.Id,
         commandRequest.Value,
         commandRequest.RegisterDate
     }, commandType : CommandType.StoredProcedure);
 }
Exemplo n.º 3
0
        public async Task <HandlerResultEntity <object> > Handle(UpdateSalaryCommandRequest commandRequest, CancellationToken cancellationToken)
        {
            var validationResult = await validator.ValidateAsync(commandRequest, cancellationToken);

            if (validationResult.IsValid)
            {
                switch (await salaryRepository.VerifySalaryExistsById(commandRequest.Id))
                {
                case true:
                {
                    await salaryRepository.UpdateSalaryAsync(commandRequest);

                    return(new HandlerResultEntity <object>(true, string.Empty, null));
                }

                case false: return(new HandlerResultEntity <object>(false, "salary id doenst exists", null));
                }
            }
            else
            {
                return(new HandlerResultEntity <object>(false, ValidationResultErrorMessage.Format(validationResult), null));
            }
        }