コード例 #1
0
        public JsonResult IndexAjax(DataTableJS data)
        {
            String search = null;

            if (data.search != null && data.search["value"] != null)
            {
                search = data.search["value"];
            }
            var    column      = data.order[0]["column"];
            var    dir         = data.order[0]["dir"];
            string columnName  = ((String[])data.columns[int.Parse(column)]["data"])[0];
            var    queryFilter =
                _service.GetIQueryableItems()
                .Where(
                    T => T.Active == 1 &&
                    (search == "" || (search != null &&
                                      (T.KeySearch.ToLower().Contains(search.ToLower())))));

            if (dir == "asc")
            {
                queryFilter = queryFilter.OrderByField(columnName, true);
            }
            else
            {
                queryFilter = queryFilter.OrderByField(columnName, false);
            }
            data.recordsTotal    = _service.GetIQueryableItems().Where(T => T.Active == 1).Count();
            data.recordsFiltered = queryFilter.Count();
            data.data            = queryFilter.Skip(data.start)
                                   .Take(data.length == -1 ? data.recordsTotal : data.length)
                                   .ToList().Select(T => new {
                ID          = T.ID,
                Title       = T.Title,
                BDSNewsType = new BDSNewsType {
                    ID = T.BDSNewsType.ID, Name = T.BDSNewsType.Name
                },
                NameCompany = T.NameCompany,
                BDSAccount  = new BDSAccount {
                    ID = T.BDSAccount.ID, Email = T.BDSAccount.Email
                },
                DesCompany     = T.DesCompany,
                FromCreateNews = T.FromCreateNews.Value.ToString(MvcApplication.DateTimeFormat.ShortDatePattern),
                ToCreateNews   = T.ToCreateNews.Value.ToString(MvcApplication.DateTimeFormat.ShortDatePattern),
                Status         = T.Status
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
 public PartialViewResult IndexPendingByType()
 {
     return(PartialView(_service.GetIQueryableItems().Where(T => T.Active == 1 && T.Status == 0).OrderBy(T => T.BDSNewsType.Order).ThenBy(T => T.CreateDate).ToList()));
 }