public ActionResult Delete(int index, int id) { var model = new FreightForwarderListModel(); model.GridIndex = index; try { LookupService.DeleteFreightForwarder(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public FreightForwarderListModel FindFreightForwardersListModel(int companyId, int index, int pageNo, int pageSize, string search) { var model = new FreightForwarderListModel(); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindFreightForwarders(companyId, true) .Where(ff => string.IsNullOrEmpty(search) || (ff.Name != null && ff.Name.ToLower().Contains(search.ToLower())) || (ff.Address != null && ff.Address.ToLower().Contains(search.ToLower())) || (ff.Phone != null && ff.Phone.ToLower().Contains(search.ToLower())) || (ff.Email != null && ff.Email.ToLower().Contains(search.ToLower()))); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var newItem = MapToModel(item); model.Items.Add(newItem); } return(model); }