Exemple #1
0
 public ActionResult Index()
 {
     var model = new RoleSearchViewModel();
     ViewBag.Data_ControllerID = Utilities.GetSelectListData(
      ControllerService.GetALL(), x => x.ID, x => x.Name, true);
     return View(model);
 }
Exemple #2
0
        public ActionResult getall(RoleSearchViewModel model, int page = 1, int rows = 10)
        {
            var query = RoleService.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 RoleListViewModel()
            {
                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);
        }