Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreatePaymentApiModel createPaymentApiModel)
        {
            var paymentRequest = _paymentMapper.Map(createPaymentApiModel);

            var validationResult = _paymentRequestValidator.Validate(paymentRequest);

            if (validationResult.Error != ValidationErrors.none)
            {
                return(BadRequest(new ErrorResponse {
                    ErrorCode = _errorToApiErrorCodeMapper.Map(validationResult.Error),
                    ErrorMessage = validationResult.ErrorMessage
                }));
            }

            var payment = await _paymentManager.AddPayment(paymentRequest);

            return(Ok(_paymentMapper.Map(payment)));
        }
Ejemplo n.º 2
0
        public PaymentDto AddPayment(PaymentDto payment)
        {
            var userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value;

            return(_paymentManager.AddPayment(payment, int.Parse(userId)));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> CreatePayment([FromBody] PaymentRequest request)
        {
            var result = await _paymentManager.AddPayment(request);

            return(Ok(result));
        }