Example #1
0
        public JsonResult GetUserList(int page, int rows)
        {
            var users = Manager.GetAll(page, rows);
            var userCount = Manager.GetAllCount();

            var userList = users.Select(user => new UserItem
                {
                    Id = user.Id,
                    UserName = user.UserName,
                    Email = user.Email,
                    EmailConfirmed = user.EmailConfirmed,
                    PhoneNumber = user.PhoneNumber,
                    PhoneNumberConfirmed = user.PhoneNumberConfirmed,
                    LockoutEnabled = user.LockoutEnabled,
                    LockoutEndDate = user.LockoutEndDateUtc.HasValue
                        ? user.LockoutEndDateUtc.Value.ToShortDateString()
                        : string.Empty,
                    City = user.City,
                    AvatarName = user.AvatarName,
                    FirstName = user.ClientDataId.HasValue ? user.ClientData.FirstName : string.Empty,
                    LastName = user.ClientDataId.HasValue ? user.ClientData.LastName : string.Empty,
                    Type = user.Roles.Count() > 0 ? RoleManager.GetRoleByUserId(user.Id) : "None"
                })
                .OrderByDescending(c => c.Id)
                .ToList();

            var jsonData = new
            {
                total = Math.Ceiling(userCount / (double)rows),
                page = page,
                records = userCount,
                rows = userList
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }