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)); }
public PaymentMethodViewModel Create(PaymentMethodViewModel vm) { var paymentMethod = Mapper.Map <PaymentMethod>(vm); var result = _paymentMethodRepository.Add(paymentMethod); return(Mapper.Map <PaymentMethodViewModel>(result)); }
public void AddPaymentMethod(PaymentMethodViewModel viewModel) { var paymentMethod = new PaymentMethod { Name = viewModel.Name, Cost = viewModel.Cost, }; _paymentMethodRepository.Add(paymentMethod); _paymentMethodRepository.SaveChanges(); }
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); }
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); }
public PaymentMethod Insert(PaymentMethod entity) { return(_PaymentMethodRepository.Add(entity)); }