예제 #1
0
        public ActionResult GetAllEmailTemplates(jQueryDataTableParamModel param)
        {
            try
            {
                var allRecords = new List <EmailTemplate>();
                allRecords = MS.GetAllEmailTemplates(param);
                List <EmailTemplate> filteredRecords = null;

                if (!string.IsNullOrWhiteSpace(param.sSearch))
                {
                    allRecords      = allRecords.Where(t => t.Id.ToString().Contains(param.sSearch.ToLower()) || t.Title.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.Body.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.SystemName.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.Subject.ToLower().ToString().Contains(param.sSearch.ToLower())).OrderBy(t => t.Title).ToList();
                    filteredRecords = allRecords.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList();
                }
                else
                {
                    filteredRecords = allRecords
                                      .Skip(param.iDisplayStart)
                                      .Take(param.iDisplayLength).OrderBy(t => t.Title).ToList();
                }
                int totalRecords = allRecords.Count();
                var result       = from c in filteredRecords select new[] { "", c.Id.ToString(), c.Title, c.Subject, c.SystemName, c.Body, "" };
                return(Json(new
                {
                    sEcho = param.sEcho,
                    iTotalRecords = totalRecords,
                    iTotalDisplayRecords = totalRecords,
                    aaData = result
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    sEcho = 1,
                    iTotalRecords = 0,
                    iTotalDisplayRecords = 0,
                    aaData = new List <string[]> {
                    }
                }, JsonRequestBehavior.AllowGet));
            }
        }