public SupplierAddressListModel FindSupplierAddressesListModel(int supplierId, int index, int pageNo, int pageSize, string search) { var model = new SupplierAddressListModel(); model.GridIndex = index; var allItems = db.FindSupplierAddresses(supplierId) .Where(sa => string.IsNullOrEmpty(search) || (sa.Street != null && sa.Street.ToLower().Contains(search.ToLower())) || (sa.City != null && sa.City.ToLower().Contains(search.ToLower())) || (sa.State != null && sa.State.ToLower().Contains(search.ToLower())) || (sa.Postcode != null && sa.Postcode.ToLower().Contains(search.ToLower())) || (sa.StreetLine1 != null && sa.StreetLine1.ToLower().Contains(search.ToLower())) || (sa.StreetLine2 != null && sa.StreetLine2.ToLower().Contains(search.ToLower())) || (sa.StreetLine3 != null && sa.StreetLine3.ToLower().Contains(search.ToLower())) || (sa.StreetLine4 != null && sa.StreetLine4.ToLower().Contains(search.ToLower()))) .OrderByDescending(sa => sa.Street); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var newItem = mapToModel(item); newItem.AddressTypeText = (item.LOVItem_AddressType == null ? "" : item.LOVItem_AddressType.ItemText); model.Items.Add(newItem); } return(model); }
public ActionResult Delete(int index, int id) { var model = new SupplierAddressListModel(); model.GridIndex = index; try { SupplierService.DeleteSupplierAddress(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }