public async Task <IActionResult> Create([FromBody] PaymentMethod paymentMethod)
        {
            if (!ModelState.IsValid)
            {
                return(HttpBadRequest());
            }
            try
            {
                await _service.AddPaymentMethodAsync(paymentMethod);

                return(CreatedAtRoute("GetPaymentMethod", new { controller = "PaymentMethods", id = paymentMethod.Id },
                                      paymentMethod));
            }
            catch (PaymentMethodInvalidException)
            {
                return(HttpBadRequest());
            }
        }
Exemple #2
0
        public async Task <IActionResult> CreatePaymentMethodAsync(PaymentMethod paymentMethod)
        {
            await _paymentService.AddPaymentMethodAsync(paymentMethod);

            return(Ok(paymentMethod));
        }