コード例 #1
0
ファイル: GroupController.cs プロジェクト: navy235/CommonP
 public ActionResult Index()
 {
     var model = new GroupSearchViewModel();
     ViewBag.Data_ControllerID = Utilities.GetSelectListData(
      ControllerService.GetALL(), x => x.ID, x => x.Name, true);
     return View(model);
 }
コード例 #2
0
ファイル: GroupController.cs プロジェクト: navy235/CommonP
        public ActionResult getall(GroupSearchViewModel model, int page = 1, int rows = 10)
        {
            var query = GroupService.GetALL();

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

            var count = query.Count();

            var data = query.Select(x => new GroupListViewModel()
            {
                ID = x.ID,
                Description = x.Description,
                Name = x.Name
            })
                .OrderBy(x => x.ID)
                .Skip((page - 1) * rows)
                .Take(rows).ToList();

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