public async Task <ActionResult> PostRateAsync(PayrollRateCreateDto payrollRateCreateDto) { try { var mappedModel = _mapper.Map <PayrollRate>(payrollRateCreateDto); await _rateRepository.CreateRateAsync(mappedModel); await _rateRepository.SaveAsync(); var createdReadModel = _mapper.Map <PayrollRateReadDto>(mappedModel); return(CreatedAtRoute(nameof(GetASync), new { Id = createdReadModel.RateId }, createdReadModel)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Success = false, Message = ex.Message })); } }
public async Task <ActionResult> PutAsync(int id, PayrollRateCreateDto payrollRateCreateDto) { try { var rate = await _rateRepository.GetRateByIdAsync(id); if (rate == null) { return(NotFound()); } var putmodel = _mapper.Map(payrollRateCreateDto, rate); await _rateRepository.SaveAsync(); return(NoContent()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Success = false, Message = ex.Message })); } }