public JsonResult IndexAjax(DataTableJS data)
        {
            var    itmes  = _service.GetIQueryableItems().ToList();
            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();
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        void LoadDataList()
        {
            List <ShowDrop> listSalary = new List <ShowDrop>();

            for (int i = 0; i <= 100; i++)
            {
                var valueshow = new ShowDrop
                {
                    Value = i,
                    Text  = i + " Triệu"
                };
                listSalary.Add(valueshow);
            }
            var Cities = (from a in db.States
                          join b in db.StateTexts on a.name_id equals b.id
                          where b.language_id == "vi" && a.Status == 1
                          select new { ID = a.state_id, Name = b.text }).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();


            var Educations = _serviceEducation.GetIQueryableItems().Where(T => T.Active == 1).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();
            var NewsTypes = _serviceNewsType.GetIQueryableItems().Where(T => T.Active == 1).OrderBy(T => T.Order).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();
            var NewsTypePrices = _serviceNewsTypePrice.GetIQueryableItems().Where(T => T.Active == 1).ToList();
            var TimeWorks      = _serviceTimeWork.GetIQueryableItems().Where(T => T.Active == 1).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();
            var Careers = _serviceCareer.GetIQueryableItems().Where(T => T.Active == 1).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();
            var Languages = _serviceLanguage.GetIQueryableItems().Where(T => T.Active == 1).ToList().Select(T => new SelectListItem {
                Value = T.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();
            var EmployerInformations = _serviceEmployerInformation.GetIQueryableItems().Where(T => T.Active == 1).ToList().Select(T => new SelectListItem {
                Value = T.BDSAccount.ID.ToString(), Text = T.Name.ToString(), Selected = false
            }).ToList();

            Cities.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });

            Educations.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });
            NewsTypes.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });
            TimeWorks.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });
            EmployerInformations.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });
            Languages.Insert(0, new SelectListItem {
                Value = "", Text = "Chọn", Selected = true
            });

            ViewBag.Cities         = Cities;
            ViewBag.Educations     = Educations;
            ViewBag.NewsTypes      = NewsTypes;
            ViewBag.NewsTypePrices = NewsTypePrices;
            ViewBag.TimeWorks      = TimeWorks;
            ViewBag.Careers        = Careers;
            ViewBag.Languages      = Languages;
            ViewBag.ListSalary     = listSalary.ToList().Select(T => new SelectListItem {
                Value = T.Value.ToString(), Text = T.Text.ToString(), Selected = false
            }).ToList();
            ViewBag.EmployerInformations = EmployerInformations;
        }