コード例 #1
0
        public async Task <ActionResult <PaymentModel> > CreatePaymentAsync(PaymentModel model)
        {
            var validationResult = _paymentModelValidationProvider.Validate(model);

            if (validationResult != null)
            {
                return(validationResult);
            }

            var dto = new PaymentDto
            {
                CardHolderName = model.CardHolderName,
                CardNumber     = model.CardNumber,
                ExpiryDate     = model.ExpiryDate,
                Amount         = model.Amount,
                Currency       = model.Currency,
                Cvv            = model.Cvv,
                PaymentDate    = DateTime.Now,
                State          = PaymentState.New
            };

            var res = await _paymentBLL.CreatePaymentAsync(dto);

            if (!res)
            {
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }

            return(dto.ToModel());
        }