Beispiel #1
0
        public ActionResult Listing()
        {
            UsersListingViewModel model = new UsersListingViewModel();

            model.Users = UserManager.Users.ToList();
            return(PartialView("_Listing", model));
        }
Beispiel #2
0
        public ActionResult UsersListing(string roleID, string searchTerm, int?pageNo)
        {
            var pageSize = 5;
            UsersListingViewModel model = new UsersListingViewModel();

            model.RoleID     = roleID;
            model.SearchTerm = searchTerm;
            //model.Users = UserManager.Users.ToList();

            var users = UserManager.Users;  //.AsQueryable();

            if (!string.IsNullOrEmpty(roleID))
            {
                //users = users.Where(x => x.Roles.Where(y => y.RoleId == roleID).Count()>0);
                users = users.Where(x => x.Roles.FirstOrDefault(y => y.RoleId == roleID) != null);
            }

            if (!string.IsNullOrEmpty(searchTerm))
            {
                users = users.Where(x => x.Email.ToLower().Contains(searchTerm.ToLower()));
            }

            pageNo = pageNo ?? 1;
            //pageNo = pageNo.HasValue ? pageNo.Value : 1;

            var skipCount = (pageNo.Value - 1) * pageSize;

            model.Users = users.OrderByDescending(x => x.Roles.Count).Skip(skipCount).Take(pageSize).ToList();

            model.Pager = new Pager(users.Count(), pageNo, pageSize);
            //model.PageNo = pageNo ?? 1;

            return(PartialView(model));
        }
        public ActionResult Index(string roleID, string searchTerm, int?pageNo)
        {
            var pageSize = (int)RecordSizeEnums.Size10;

            UsersListingViewModel model = new UsersListingViewModel
            {
                RoleID     = roleID,
                SearchTerm = searchTerm,

                Roles = RoleManager.Roles.ToList()
            };

            var users = UserManager.Users;

            if (!string.IsNullOrEmpty(roleID))
            {
                users = users.Where(x => x.Roles.FirstOrDefault(y => y.RoleId == roleID) != null);
            }

            if (!string.IsNullOrEmpty(searchTerm))
            {
                users = users.Where(x => x.Email.ToLower().Contains(searchTerm.ToLower()) || x.UserName.ToLower().Contains(searchTerm.ToLower()));
            }

            pageNo = pageNo ?? 1;
            var skipCount = (pageNo.Value - 1) * pageSize;

            model.Users = users.OrderByDescending(x => x.RegisteredOn).Skip(skipCount).Take(pageSize).ToList();

            model.Pager = new Pager(users.Count(), pageNo, pageSize);

            return(View(model));
        }
Beispiel #4
0
        public async Task <IActionResult> Index(int page = 1)
        {
            var model = new UsersListingViewModel
            {
                Users       = await this.adminService.GetAllUsersAsync(page),
                TotalUsers  = await this.adminService.GetTotalUsersCountAsync(),
                CurrentPage = page
            };

            return(View(model));
        }
Beispiel #5
0
        public async Task <IActionResult> Index()
        {
            var allUsers = await this.users.AllAsync();

            var roles = this.roleManager.Roles
                        .Select(r => new SelectListItem
            {
                Text  = r.Name,
                Value = r.Name
            })
                        .ToList();

            var usersListing = new UsersListingViewModel
            {
                UsersListing = allUsers,
                Roles        = roles
            };

            return(this.View(usersListing));
        }
Beispiel #6
0
        public async Task <IActionResult> Index()
        {
            var users = this.usersData.GetAll().ProjectTo <AdminUsersListingViewModel>().ToList();
            var roles = await this.roleManager
                        .Roles
                        .Select(r => new SelectListItem
            {
                Text  = r.Name,
                Value = r.Name
            })
                        .ToListAsync();

            var model = new UsersListingViewModel
            {
                Users = users,
                Roles = roles
            };

            return(this.View(model));
        }
Beispiel #7
0
        // GET: Dashboard/Users
        public ActionResult Index(string searchTerm, string roleId, int?pageNo)
        {
            int recordSize = 5;

            pageNo = pageNo ?? 1;

            UsersListingViewModel model = new UsersListingViewModel();

            model.SearchTerm = searchTerm;
            model.RoleId     = roleId;
            model.Roles      = RoleManager.Roles.ToList();

            model.Users = SearchUsers(searchTerm, roleId, pageNo.Value, recordSize);

            var totalRecords = SearchUsersCount(searchTerm, roleId);

            model.Pager = new Pager(totalRecords, pageNo, recordSize);

            return(View(model));
        }
Beispiel #8
0
        // GET: DashBoard/User
        public ActionResult Index(string searchTerm, string roleID, int?page)
        {
            UsersListingViewModel model = new UsersListingViewModel();

            //model.Users = Userservice.GetAllUsers();
            model.Users       = SearchUsers(searchTerm, roleID);
            model.totalRecord = model.Users.Count();

            //pagination logic start from here
            var pager = new Pager(model.totalRecord, page);

            model.Users =
                model.Users.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList();

            model.SearchTerm = searchTerm;
            model.Roles      = RoleManager.Roles;
            model.RoleID     = roleID;

            model.pager = pager;

            return(View(model));
        }
Beispiel #9
0
        public ActionResult Users(string search, int?page, int?items)
        {
            UsersListingViewModel model = new UsersListingViewModel();

            model.PageInfo = new PageInfo()
            {
                PageTitle       = "Users",
                PageDescription = "AssessmentTool Users."
            };

            model.searchTerm = search;
            model.pageNo     = page ?? 1;
            model.pageSize   = items ?? 10;

            var usersSearch = UsersService.Instance.GetUsersWithRoles(model.searchTerm, model.pageNo, model.pageSize);

            model.Users      = usersSearch.Users;
            model.TotalCount = usersSearch.TotalCount;

            model.Pager = new Pager(model.TotalCount, model.pageNo, model.pageSize);

            return(PartialView("_Users", model));
        }
Beispiel #10
0
        public ActionResult Index(string roleID, string searchTerm, int?pageNo)
        {
            var pageSize = ConfigurationsHelper.DashboardRecordsSizePerPage;

            UsersListingViewModel model = new UsersListingViewModel();

            model.PageTitle       = "Users";
            model.PageDescription = "Users Listing Page";

            model.RoleID     = roleID;
            model.SearchTerm = searchTerm;

            model.Roles = RoleManager.Roles.ToList();

            var users = UserManager.Users;

            if (!string.IsNullOrEmpty(roleID))
            {
                users = users.Where(x => x.Roles.FirstOrDefault(y => y.RoleId == roleID) != null);
            }

            if (!string.IsNullOrEmpty(searchTerm))
            {
                users = users.Where(x => x.Email.ToLower().Contains(searchTerm.ToLower()) || x.UserName.ToLower().Contains(searchTerm.ToLower()));
            }

            pageNo = pageNo ?? 1;

            var skipCount = (pageNo.Value - 1) * pageSize;

            model.Users = users.OrderBy(x => x.Email).Skip(skipCount).Take(pageSize).ToList();

            model.Pager = new Pager(users.Count(), pageNo, pageSize);

            return(View(model));
        }