public async Task <IActionResult> PutAsync(int id, [FromBody] SavePaymentLetterResource resource) { var paymentLetter = _mapper.Map <SavePaymentLetterResource, PaymentLetter>(resource); var result = await _paymentLetterService.UpdateAsync(id, paymentLetter); if (!result.Succes) { return(BadRequest(result.Message)); } var paymentLetterResource = _mapper.Map <PaymentLetter, PaymentLetterResource>(result.Resource); return(Ok(paymentLetterResource)); }
public async Task <IActionResult> PostAsync([FromBody] SavePaymentLetterResource resource, int userId) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var paymentLetter = _mapper.Map <SavePaymentLetterResource, PaymentLetter>(resource); var result = await _paymentLetterService.SaveAsync(paymentLetter, userId); if (!result.Succes) { return(BadRequest(result.Message)); } var paymentLetterResource = _mapper.Map <PaymentLetter, PaymentLetterResource>(result.Resource); return(Ok(paymentLetterResource)); }