/// <summary> /// Prepare paged Qualpay customer card list model /// </summary> /// <param name="searchModel">Qualpay customer card search model</param> /// <param name="customer">Customer</param> /// <returns>Qualpay customer card list model</returns> public QualpayCustomerCardListModel PrepareQualpayCustomerCardListModel(QualpayCustomerCardSearchModel searchModel, Customer customer) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (customer == null) { throw new ArgumentNullException(nameof(customer)); } //try to get customer billing cards var billingCards = _qualpayManager.GetCustomerCards(customer.Id).ToList().ToPagedList(searchModel); //prepare list model var model = new QualpayCustomerCardListModel().PrepareToGrid(searchModel, billingCards, () => { return(billingCards.Select(card => new QualpayCustomerCardModel { Id = card.CardId, CardId = card.CardId, CardType = card.CardType?.ToString(), ExpirationDate = card.ExpDate, MaskedNumber = card.CardNumber })); }); return(model); }
public IActionResult QualpayCustomerCardList(QualpayCustomerCardSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) { return(AccessDeniedDataTablesJson()); } //try to get a customer with the specified id var customer = _customerService.GetCustomerById(searchModel.CustomerId) ?? throw new ArgumentException("No customer found with the specified id"); //prepare model var model = _qualpayCustomerModelFactory.PrepareQualpayCustomerCardListModel(searchModel, customer); return(Json(model)); }