示例#1
0
 public ActionResult Index()
 {
     var model = new ActionSearchViewModel();
     ViewBag.Data_ControllerID = Utilities.GetSelectListData(
      ControllerService.GetALL(), x => x.ID, x => x.Name, true);
     return View(model);
 }
示例#2
0
        public ActionResult getall(ActionSearchViewModel model, int page = 1, int rows = 10)
        {
            var query = ActionService.GetALL()
                .Include(x => x.Controller);

            if (!string.IsNullOrEmpty(model.ActionName))
            {
                query = query.Where(x => x.Name.Contains(model.ActionName));
            }
            if (model.ControllerID.HasValue)
            {
                query = query.Where(x => x.ControllerID == model.ControllerID.Value);
            }
            var count = query.Count();

            var data = query.Select(x => new ActionListViewModel()
                {
                    ID = x.ID,
                    ControllerID = x.ControllerID,
                    ControllerName = x.Controller.Name,
                    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);
        }