Beispiel #1
0
 public ActionResult Index()
 {
     var model = new DepartmentSearchViewModel();
     return View(model);
 }
Beispiel #2
0
        public ActionResult getall(DepartmentSearchViewModel model, int page = 1, int rows = 500)
        {
            var query = DepartmentService.GetALL();

            if (!string.IsNullOrEmpty(model.Department_SearchName))
            {
                query = query.Where(x => x.Name.Contains(model.Department_SearchName));
            }

            var count = query.Count();

            var data = query.Select(x => new DepartmentListViewModel()
            {
                ID = x.ID,

                Name = x.Name,

                Description = x.Description,

                LeaderID = x.LeaderID,

                _parentId = x.PID,

                PID = x.PID,

                Code = x.Code,

                Level = x.Level,

            })
            .OrderBy(x => x.ID)
            .Skip((page - 1) * rows)
            .Take(rows).ToList();

            var obj = new
            {
                rows = data,
                total = count
            };
            return Json(obj);
        }