public ActionResult Delete(int index, int id) { var model = new EMailQueueListModel(); model.GridIndex = index; try { EMailService.DeleteEMailQueue(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public EMailQueueListModel FindEMailQueueListModel(int index, int pageNo, int pageSize, string search) { var model = new EMailQueueListModel(); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindEMailQueues() .Where(eq => string.IsNullOrEmpty(search) || (eq.MessageSubject != null && eq.MessageSubject.ToLower().Contains(search.ToLower())) || (eq.MessageText != null && eq.MessageText.ToLower().Contains(search.ToLower()))); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var newItem = mapToModel(item); newItem.AttachmentCount = item.EMailQueueAttachments.Count(); model.Items.Add(newItem); } return(model); }