コード例 #1
0
        public async Task <IActionResult> ExecuteAsync(SavePaymentMethod savePaymentMethod, CancellationToken cancellationToken)
        {
            var paymentMethod = _paymentMethodToSavePaymentMethodMapper.Map(savePaymentMethod);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub")?.Value;

            //paymentMethod.CreatedBy = userId;

            paymentMethod = await _paymentMethodRepository.Add(paymentMethod, cancellationToken);

            var paymentMethodViewModel = _paymentMethodToPaymentMethodMapper.Map(paymentMethod);

            return(new CreatedAtRouteResult(
                       PaymentMethodsControllerRoute.GetPaymentMethod,
                       new { id = paymentMethodViewModel.Id },
                       paymentMethodViewModel));
        }
コード例 #2
0
        public PaymentMethodViewModel Create(PaymentMethodViewModel vm)
        {
            var paymentMethod = Mapper.Map <PaymentMethod>(vm);

            var result = _paymentMethodRepository.Add(paymentMethod);

            return(Mapper.Map <PaymentMethodViewModel>(result));
        }
コード例 #3
0
        public void AddPaymentMethod(PaymentMethodViewModel viewModel)
        {
            var paymentMethod = new PaymentMethod
            {
                Name = viewModel.Name,
                Cost = viewModel.Cost,
            };

            _paymentMethodRepository.Add(paymentMethod);
            _paymentMethodRepository.SaveChanges();
        }
コード例 #4
0
        public BaseViewModel <PaymentMethodViewModel> CreatePaymentMethod(CreatePaymentMethodRequestViewModel paymentMethod)
        {
            var entity = _mapper.Map <PaymentMethod>(paymentMethod);

            entity.Id = Guid.NewGuid();
            entity.SetDefaultInsertValue(_repository.GetUsername());
            entity.UserId = new Guid(_repository.GetCurrentUserId());
            _repository.Add(entity);

            var result = new BaseViewModel <PaymentMethodViewModel>()
            {
                Data = _mapper.Map <PaymentMethodViewModel>(entity),
            };

            Save();

            return(result);
        }
コード例 #5
0
        public async Task Handle(CreatePaymentCommand command)
        {
            _logger.LogInformation($"----- Sending command: paymentRequestCommand, MerchantId:{command.MerchantId}, Amount:{command.Amount})");

            var paymentMethod = new PaymentMethod()
            {
                Id = command.Id,
                AcquiringBankId = command.MerchantId,
                MerchantId      = command.MerchantId,
                Amount          = command.Amount,
                CardExpiry      = command.CardExpiry,
                CardNumber      = command.CardNumber,
                CurrencyCode    = command.Currency,
                CVV             = command.CardCvv,

                TransactionId    = command.TransactionId,
                Status           = command.PaymentStatus,
                ErrorDescription = command.ErrorDescription
            };

            await _paymentMethodRepository.Add(paymentMethod);
        }
コード例 #6
0
 public PaymentMethod Insert(PaymentMethod entity)
 {
     return(_PaymentMethodRepository.Add(entity));
 }