예제 #1
0
        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));
        }
예제 #2
0
        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));
        }