public ActionResult Delete(int index, int id) { var model = new FreightCarrierListModel(); model.GridIndex = index; try { LookupService.DeleteFreightCarrier(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public FreightCarrierListModel FindFreightCarriersListModel(int companyId, int index = 0, int pageNo = 1, int pageSize = Int32.MaxValue, string search = "") { var model = new FreightCarrierListModel(); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindFreightCarriers(companyId, true) .Where(c => string.IsNullOrEmpty(search) || (c.FreightCarrier1 != null && c.FreightCarrier1.ToLower().Contains(search.ToLower())) || (c.HTTPPrefix != null && c.HTTPPrefix.ToLower().Contains(search.ToLower()))); model.TotalRecords = allItems.Count(); model.Items = allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize) .Select(c => new FreightCarrierModel { Id = c.Id, CompanyId = companyId, FreightCarrier = c.FreightCarrier1, HTTPPrefix = (string.IsNullOrEmpty(c.HTTPPrefix) ? "" : c.HTTPPrefix), AutoBuildTrackingLink = c.AutoBuildTrackingLink, Enabled = c.Enabled }).ToList(); return(model); }