예제 #1
0
        //[HttpGet]
        public async Task <IActionResult> Index(string _query = "", string _sort = "", string _order = "", int _start = 0, int _end = 0)
        {
            var allUsers = (IEnumerable <ApplicationUser>)_userManager.Users;

            HashSet <string> searchableProperties = new HashSet <string>();

            searchableProperties.Add("Email");
            searchableProperties.Add("UserName");

            allUsers = _paginationService.Filter(allUsers, _query, searchableProperties);
            allUsers = _paginationService.Sort(allUsers, _sort, _order, searchableProperties);
            var countOfUsers = allUsers.Count();

            allUsers = _paginationService.Partition(allUsers, _start, _end);

            var result = new List <UserDTO>();

            for (int i = 0; i < allUsers.Count(); i++)
            {
                var roles = (await _userManager.GetRolesAsync(allUsers.ElementAt(i))).ToDictionary(x => x, x => true);
                result.Add(new UserDTO()
                {
                    Id = allUsers.ElementAt(i).Id, Email = allUsers.ElementAt(i).Email, Password = allUsers.ElementAt(i).PasswordHash, UserName = allUsers.ElementAt(i).UserName, FullName = allUsers.ElementAt(i).FullName, Address = allUsers.ElementAt(i).Address, BirthDay = allUsers.ElementAt(i).BirthDay, Height = allUsers.ElementAt(i).Height, Weight = allUsers.ElementAt(i).Weight, Roles = roles
                });
            }
            return(View("Views/Admin/Users/Index.cshtml", result));
        }
예제 #2
0
        public virtual IActionResult GetGeneric(string _query = "",
                                                HashSet <string> searchableProperties = null,
                                                string _sort = "", string _order = "", int _start = 0, int _end = 0)
        {
            dynamic items = repo.GetAll();

            items = _paginationService.Filter(items, _query, searchableProperties);
            int totalCount = items.Count;

            items = _paginationService.Sort(items, _sort, _order, searchableProperties);
            items = _paginationService.Partition(items, _start, _end);

            return(new ObjectResult(items));
        }