コード例 #1
0
        public ActionResult DeleteUser(int?id, string name, int page)
        {
            var model = new UserEditorVIewModel();

            if (!ReferenceEquals(id, null))
            {
                _userService.DeleteUser(Convert.ToInt32(id));
            }
            List <UserViewModel> users;

            if (ReferenceEquals(name, null))
            {
                users          = _userService.GetAllUsers().Select(u => u.ToMvcUser()).ToList();
                model.Users    = users;
                model.PageInfo = new PageInfoViewModel(page, 10, users.Count, null);
            }
            else
            {
                users          = _userService.GetAllUsers().Select(u => u.ToMvcUser()).Where(a => a.Name.Contains(name) || a.Email.Contains(name)).ToList();
                model.Users    = users;
                model.PageInfo = new PageInfoViewModel(page, 10, users.Count, name);
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("UsersEditor", model));
            }


            return(View("UsersEditor", model));
        }
コード例 #2
0
        public ActionResult UsersEditor(string searchItem, int page = 1)
        {
            var model = new UserEditorVIewModel();
            List <UserViewModel> users;

            if (ReferenceEquals(searchItem, null))
            {
                users =
                    _userService.GetAllUsers()
                    .Select(u => u.ToMvcUser())
                    .ToList();
                model.PageInfo = new PageInfoViewModel(page, 10, users.Count, null);
            }
            else
            {
                users =
                    _userService.GetAllUsers()
                    .Select(u => u.ToMvcUser())
                    .Where(a => a.Name.Contains(searchItem) || a.Email.Contains(searchItem))
                    .ToList();
                model.PageInfo = new PageInfoViewModel(page, 10, users.Count, searchItem);
            }
            model.Users = users.Skip((page - 1) * 10).Take(10);
            if (Request.IsAjaxRequest())
            {
                return(PartialView(model));
            }
            return(View(model));
        }