public CreditCardListModel FindCreditCardsListModel(int companyId, int customerId, int index, int pageNo, int pageSize) { var model = new CreditCardListModel(); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindCreditCards(companyId, customerId); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { model.Items.Add(MapToModel(item, true)); } return(model); }
public ActionResult Delete(int index, int id) { var model = new CreditCardListModel(); model.GridIndex = index; // Check if the card is attached to any sales int saleCount = SalesService.FindCreditCardSales(CurrentCompany, id).Items.Count(); if (saleCount > 0) { model.Error.SetError(EvolutionResources.errCantDeleteCreditCardAttachedToSales, "", saleCount.ToString()); } else { try { CustomerService.DeleteCreditCard(id); } catch (Exception e1) { model.Error.SetError(e1); } } return(Json(model, JsonRequestBehavior.AllowGet)); }