Esempio n. 1
0
        public async Task <IActionResult> Unlock(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ApplicationUser user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                return(NotFound());
            }

            if (user.LockoutEnd == null)
            {
                TempData["messageType"]  = "warning";
                TempData["messageTitle"] = "USER IS NOT LOCKED!";
                TempData["message"]      = "No updates where made to the user";
                return(RedirectToAction(nameof(Details), new { id }));
            }

            UsersListViewModel model = new UsersListViewModel
            {
                Email             = user.Email,
                FirstName         = user.FirstName,
                LastName          = user.LastName,
                AccessFailedCount = user.AccessFailedCount,
                LockoutEnd        = user.LockoutEnd
            };

            return(View(model));
        }
Esempio n. 2
0
        //TODO - verificar como restringir para apenas role CanManageUsers
        public ActionResult List()
        {
            var result = UserManager.Users.ToList();
            List <UsersListViewModel> userList = new List <UsersListViewModel>();
            UsersListViewModel        user;

            foreach (var item in result)
            {
                user             = new UsersListViewModel();
                user.Id          = item.Id;
                user.PhoneNumber = item.PhoneNumber;
                user.UserName    = item.UserName;
                user.Email       = item.Email;
                userList.Add(user);
            }

            if (User.IsInRole(RoleName.CanManageUsers))
            {
                return(View("List", userList));
            }
            else
            {
                return(View("ReadOnlyList", userList));
            }
        }
Esempio n. 3
0
        }                                                                                                                                            //ApplicationUser ve paging info larýn listesine ihtiyacýmýz var UsersListViewModel de ihtiyacýmýz olan modeli yapýyoruz

        public async Task <IActionResult> OnGet(int productPage = 1, string searchEmail = null, string searchName = null, string searchPhone = null) //varsayýlan sayfa 1
        {
            UsersListVM = new UsersListViewModel()
            {
                ApplicationUserList = await _db.ApplicationUser.ToListAsync()
            };
            StringBuilder param = new StringBuilder();

            param.Append("/Users?productPage=:"); // : sayýyla deðiþtirilecek
            param.Append("&searchName=");         // arama parametreleri eklenir
            if (searchName != null)
            {
                param.Append(searchName);
            }
            param.Append("&searchEmail=");
            if (searchEmail != null)
            {
                param.Append(searchEmail);
            }
            param.Append("&searchPhone=");
            if (searchPhone != null)
            {
                param.Append(searchPhone);
            }

            if (searchEmail != null)
            {
                UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.Email.ToLower().Contains(searchEmail.ToLower())).ToListAsync();
            }
            else
            {
                if (searchName != null)
                {
                    UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.Name.ToLower().Contains(searchName.ToLower())).ToListAsync();
                }
                else
                {
                    if (searchPhone != null)
                    {
                        UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.PhoneNumber.ToLower().Contains(searchPhone.ToLower())).ToListAsync();
                    }
                }
            }

            var count = UsersListVM.ApplicationUserList.Count;

            UsersListVM.PagingInfo = new PagingInfo
            {
                CurrentPage  = productPage,
                ItemsPerPage = SD.PaginationUsersPageSize,
                TotalItems   = count,
                UrlParam     = param.ToString()
            };

            UsersListVM.ApplicationUserList = UsersListVM.ApplicationUserList.OrderBy(p => p.Email)
                                              .Skip((productPage - 1) * SD.PaginationUsersPageSize) // ilk sayfada kayýt atlamýyoruz sonraki sayfalarda sayfada gösterinlen * sayfa sayýsý-1 kadar atlýyoruz
                                              .Take(SD.PaginationUsersPageSize).ToList();

            return(Page());
        }
Esempio n. 4
0
        public async Task <IActionResult> Index(int page = 1)
        {
            int pageSize            = 5;
            List <UserViewModel> us = new List <UserViewModel>();
            var users = await _userManager.GetUsersInRoleAsync("user");

            foreach (var user in users)
            {
                us.Add(new UserViewModel
                {
                    Id    = user.Id,
                    Email = user.Email
                });
            }
            IQueryable <UserViewModel> filterList = us.AsQueryable();
            var count = filterList.Count();
            var items = filterList.Skip((page - 1) * pageSize).
                        Take(pageSize).ToList();
            UsersListViewModel model = new UsersListViewModel
            {
                PageViewModel = new PageViewModel(count, page, pageSize),
                Users         = items
            };

            return(View(model));
        }
Esempio n. 5
0
        public PartialViewResult UsersData(UsersFilterModel model)
        {
            PagerData pager = new PagerData()
            {
                ItemsPerPage = MvcApplication.ItemsPerPage,
                CurrentPage  = model.Page ?? 1
            };

            IEnumerable <UserViewModel> users;

            if (model.UserName != null)
            {
                string userName = model.UserName.ToLower();
                users = _accountManager.GetUsers(HttpContext.GetOwinContext(), u => u.UserName.ToLower().Contains(userName), pager);
            }
            else
            {
                users = _accountManager.GetUsers(HttpContext.GetOwinContext(), pager);
            }

            UsersListViewModel usersModel = new UsersListViewModel()
            {
                Pager = pager,
                Users = users
            };

            Session["UsersPage"] = pager.CurrentPage;
            return(PartialView(usersModel));
        }
Esempio n. 6
0
        public async Task <ActionResult> Edit(UsersListViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Caso a consulta dê erro já esta sendo tratado juntamente com o update
                var user = UserManager.Users.Where(c => c.Id == model.Id).FirstOrDefault();
                if (user != null)
                {
                    user.Email       = model.Email;
                    user.UserName    = model.UserName;
                    user.PhoneNumber = model.PhoneNumber;
                }

                var result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("List", "Account"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 7
0
        public UsersListViewModel getUsersList()
        {
            UsersListViewModel model = new UsersListViewModel();

            model.userList = _mapper.Map <IList <UsersViewModel> >(_mainContext.users.ToList());
            return(model);
        }
Esempio n. 8
0
        public IEnumerable <UsersListViewModel> GetListForClient()
        {
            GroupDAL groupDAL = new GroupDAL();

            List <UsersListViewModel> liUser = new List <UsersListViewModel>();
            var modelUser = db.tbl_Users.ToList();

            foreach (var item in modelUser)
            {
                UsersListViewModel model = new UsersListViewModel();
                model.UserID         = item.UserID;
                model.GroupName      = groupDAL.GetGroupByID(item.GroupID).GroupName;
                model.UserName       = item.UserName;
                model.UserFullName   = item.UserFullName;
                model.UserDOB        = item.UserDOB.Value;
                model.UserEmail      = item.UserEmail;
                model.UserPhone      = item.UserPhone;
                model.UserExtention  = item.UserExtention;
                model.UserJoinDate   = item.UserJoinDate;
                model.UserComputer   = item.UserComputer;
                model.UserCreateDate = item.UserCreateDate;
                model.UserStatus     = item.UserStatus == true;
                model.Color          = item.UserStatus == true ? "default" : "danger";
                model.UserAddress    = item.UserAddress;
                liUser.Add(model);
            }

            return(liUser);
        }
Esempio n. 9
0
        public void Can_Paginate()
        {
            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();
            Mock <IGenericRepository <User> > mockR = new Mock <IGenericRepository <User> >();

            mockR.Setup(r => r.GetAll()).Returns(() => new User[]
            {
                new User {
                    ID = 1, FirstName = "N1"
                },
                new User {
                    ID = 2, FirstName = "N2"
                },
                new User {
                    ID = 3, FirstName = "N3"
                },
                new User {
                    ID = 4, FirstName = "N4"
                },
                new User {
                    ID = 5, FirstName = "N5"
                }
            }.AsQueryable());
            mock.Setup(u => u.Users).Returns(mockR.Object);
            UserController controller = new UserController(mock.Object);

            controller.PageSize = 3;
            UsersListViewModel result = (UsersListViewModel)controller.List(2).Model;

            User[] userArray = result.Users.ToArray();
            Assert.IsTrue(userArray.Length == 2);
            Assert.AreEqual(userArray[0].FirstName, "N4");
            Assert.AreEqual(userArray[1].FirstName, "N5");
        }
Esempio n. 10
0
        public async Task <IActionResult> Index(bool Removed = false)
        {
            try
            {
                UsersListViewModel model = new UsersListViewModel();
                model._context         = _context;
                model._emailService    = _emailService;
                model._securityOptions = _securityOptions;
                model._user            = User;

                await model.PopulateList();

                ViewData.Model = model;
            }
            catch (Exception ex)
            {
                HelperFunctions.Log(_context, PublicEnums.LogLevel.LEVEL_EXCEPTION, "Controllers.UsersController.Index", ex.Message, User, ex);
            }

            if (Removed)
            {
                ViewBag.Success = "User removed successfully";
            }

            return(View());
        }
Esempio n. 11
0
        public IActionResult Filter(int?company, string name)
        {
            IIncludableQueryable <MetanitExampleCoreMVC.Models.User, Company> users = dbUsers.Users.Include(p => p.Company);
            IQueryable <MetanitExampleCoreMVC.Models.User> usersResult = null;

            if (company != null && company != 0)
            {
                usersResult = users.Where(p => p.CompanyId == company);
            }
            else
            {
                usersResult = users;
            }

            if (!String.IsNullOrEmpty(name))
            {
                usersResult = usersResult.Where(p => p.Name.Contains(name));
            }

            List <Company> companies = dbUsers.Companies.ToList();

            // устанавливаем начальный элемент, который позволит выбрать всех
            companies.Insert(0, new Company {
                Name = "Все", Id = 0
            });

            UsersListViewModel viewModel = new UsersListViewModel
            {
                Users     = usersResult?.ToList(),
                Companies = new SelectList(companies, "Id", "Name"),
                Name      = name
            };

            return(View(viewModel));
        }
 public virtual ActionResult List(string term = "", int pageNumber = 1, int pageCount = 10,
                                  Order order = Order.Descending, UserOrderBy userOrderBy
                                              = UserOrderBy.RegisterDate, UserSearchBy userSearchBy = UserSearchBy.PhoneNumber)
 {
     #region Retrive Data
     int totalUsers;
     var users = _userService.GetDataTable(out totalUsers, term, pageNumber, pageCount, order, userOrderBy, userSearchBy);
     var model = new UsersListViewModel
     {
         UserOrderBy = userOrderBy,
         Term        = term,
         PageNumber  = pageNumber,
         Order       = order,
         UsersList   = users,
         TotalUsers  = totalUsers,
         PageCount   = pageCount
     };
     #endregion
     ViewBag.UserSearchByList = DropDown.GetUserSearchByList(userSearchBy);
     ViewBag.UserOrderByList  = DropDown.GetUserOrderByList(userOrderBy);
     ViewBag.CountList        = DropDown.GetCountList(pageCount);
     ViewBag.OrderList        = DropDown.GetOrderList(order);
     ViewBag.UserSearchBy     = userSearchBy;
     return(PartialView(MVC.Admin.User.Views._ListPartial, model));
 }
Esempio n. 13
0
        public async Task <IActionResult> OnGet(int productPage = 1, string searchName = null, string searchEmail = null, string searchCity = null)
        {
            UsersListVM = new UsersListViewModel()
            {
                ApplicationUserList = await _db.ApplicationUser.ToListAsync()
            };
            StringBuilder param = new StringBuilder();

            param.Append("/Users?productPage=:");
            param.Append("&serachName=");
            if (searchName != null)
            {
                param.Append(searchName);
            }
            param.Append("&searchEmail=");
            if (searchEmail != null)
            {
                param.Append(searchEmail);
            }
            param.Append("&searchCity=");
            if (searchCity != null)
            {
                param.Append(searchCity);
            }

            if (searchEmail != null)
            {
                UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.Email.ToLower().Contains(searchEmail.ToLower())).ToListAsync();
            }
            else
            {
                if (searchName != null)
                {
                    UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.Name.ToLower().Contains(searchName.ToLower())).ToListAsync();
                }
                else
                {
                    if (searchCity != null)
                    {
                        UsersListVM.ApplicationUserList = await _db.ApplicationUser.Where(u => u.City.ToLower().Contains(searchCity.ToLower())).ToListAsync();
                    }
                }
            }

            var count = UsersListVM.ApplicationUserList.Count;

            UsersListVM.PagingInfo = new PagingInfo
            {
                CurrentPage  = productPage,
                ItemsPerPage = SD.PaginationUsersPageSize,
                TotalItems   = count,
                UrlParam     = param.ToString()
            };

            UsersListVM.ApplicationUserList = UsersListVM.ApplicationUserList.OrderBy(p => p.Email)
                                              .Skip((productPage - 1) * SD.PaginationUsersPageSize)
                                              .Take(SD.PaginationUsersPageSize).ToList();

            return(Page());
        }
Esempio n. 14
0
        public ActionResult About(int?company, string name)
        {
            IQueryable <User> users = db.Users.Include(p => p.Company);

            if (company != null && company != 0)
            {
                users = users.Where(p => p.CompanyId == company);
            }
            if (!String.IsNullOrEmpty(name))
            {
                users = users.Where(p => p.Name.Contains(name));
            }

            List <Company> companies = db.Companies.ToList();

            // устанавливаем начальный элемент, который позволит выбрать всех
            companies.Insert(0, new Company {
                Name = "Все", Id = 0
            });

            UsersListViewModel viewModel = new UsersListViewModel
            {
                Users     = users.ToList(),
                Companies = new SelectList(companies, "Id", "Name"),
                Name      = name
            };

            return(View(viewModel));
        }
Esempio n. 15
0
        public ActionResult ChooseBookGetter(int bookId, string searchString, int page = 1)
        {
            var model = new UsersListViewModel
            {
                Users      = repository.Users.Where(x => x.Id != System.Web.HttpContext.Current.User.Identity.GetUserId()),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = repository.Users.Count() - 1
                }
            };

            if (!String.IsNullOrEmpty(searchString))
            {
                model.Users = model.Users.Where(x =>
                                                (x.FirstName + x.LastName).ToLower().Contains(searchString.ToLower()));
                model.PagingInfo.TotalItems = model.Users.Count();
            }
            model.Users = model.Users.Skip((page - 1) * pageSize).Take(pageSize);

            ViewBag.BookId = bookId;

            return(View(model));
        }
Esempio n. 16
0
        public HttpResponseMessage Get(int page = 1, bool sortReverse = false)
        {
            var queryResult =
                repository.Users.Select(u => new
            {
                Id        = u.Id,
                Name      = u.Name,
                PetsCount = u.Pets.Count
            });

            queryResult = sortReverse ? queryResult
                          .OrderByDescending(u => u.Name)
                          .ThenByDescending(u => u.PetsCount) :

                          queryResult
                          .OrderBy(u => u.Name)
                          .ThenByDescending(u => u.PetsCount);

            queryResult = queryResult.Skip((page - 1) * size)
                          .Take(size);

            var users = new UsersListViewModel
            {
                UsersCount   = repository.Users.Count(),
                UsersArray   = queryResult,
                ItemsPerPage = size,
                SortReverse  = sortReverse
            };


            return(Request.CreateResponse(HttpStatusCode.OK, users));
        }
Esempio n. 17
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/

        #region LIST
        //----------------------------------------------------------------------------------------------------------------------------------
        // LIST
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus List(out UsersListViewModel usersListViewModel)
        {
            // Initialize
            questStatus status = null;

            usersListViewModel = null;


            // Get query options from query string
            QueryOptions    queryOptions    = null;
            BaseListModeler baseListModeler = new BaseListModeler(this.HttpRequestBase, new UserSession());

            status = baseListModeler.ParsePagingOptions(this.HttpRequestBase, out queryOptions);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Set up query options.
            // TEMPORARY: OPTIMIZE THIS
            List <SearchField> searchFieldList = new List <SearchField>();
            SearchOptions      searchOptions   = new SearchOptions();

            searchOptions.SearchFieldList = searchFieldList;
            queryOptions.SearchOptions    = searchOptions;


            // List
            status = List(queryOptions, out usersListViewModel);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Esempio n. 18
0
        public ActionResult Index(BaseUserSessionViewModel baseUserSessionViewModel)
        {
            questStatus status = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                baseUserSessionViewModel.questStatus = status;
                return(View("Index", baseUserSessionViewModel));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(baseUserSessionViewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                baseUserSessionViewModel.questStatus = status;
                return(View("Index", baseUserSessionViewModel));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return view.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            UsersListViewModel tablesetsListViewModel = new UsersListViewModel(this.UserSession, baseUserSessionViewModel);

            return(View(tablesetsListViewModel));
        }
Esempio n. 19
0
        public async Task <IEnumerable <AppUser> > Search(string searchString)
        {
            if (!String.IsNullOrEmpty(searchString))
            {
                var UserI = await _context.Users.Where(m => m.Id.Contains(searchString)).ToArrayAsync();

                var UserE = await _context.Users.Where(m => m.Email.Contains(searchString)).ToArrayAsync();

                UsersListViewModel all = new UsersListViewModel();

                if (UserI != null && UserE != null)
                {
                    return(all.Users = UserI.Concat(UserE));
                }
                else if (UserE == null)
                {
                    return(UserI);
                }
                else if (UserI == null)
                {
                    return(UserE);
                }
            }

            return(await _context.Users.ToArrayAsync());
        }
Esempio n. 20
0
        public async Task <IActionResult> All()
        {
            var roles            = new List <PlanItRole>();
            var companyOwnerRole = await this.roleManager
                                   .FindByNameAsync(GlobalConstants.CompanyOwnerRoleName);

            if (this.User.IsInRole(GlobalConstants.CompanyOwnerRoleName))
            {
                roles = this.roleManager.Roles.ToList();
            }
            else
            {
                roles = this.roleManager
                        .Roles.Where(r => r.Name != GlobalConstants.CompanyOwnerRoleName)
                        .ToList();
            }

            this.ViewData["Roles"] = roles.Select(role => new RoleAddToRoleViewModel
            {
                Name = role.Name,
            });

            var users = await this.usersService.GetAllAsync <UserViewModel>(this.User);

            await this.AddRolesToUsers(users);

            var model = new UsersListViewModel
            {
                Users = users,
            };

            this.ViewData["Users"] = model;

            return(this.View());
        }
Esempio n. 21
0
        public async Task <IActionResult> OnGet(int productPage = 1)
        {
            UsersListVM = new UsersListViewModel()
            {
                ApplicationUserList = await _db.ApplicationUser.ToListAsync()
            };

            StringBuilder param = new StringBuilder();

            param.Append("/Users?productPage=:");

            var count = UsersListVM.ApplicationUserList.Count;

            UsersListVM.PagingInfo = new PagingInfo
            {
                CurrentPage  = productPage,
                ItemsPerPage = SD.PaginationUsersPageSize,
                TotalItems   = count,
                UrlParam     = param.ToString()
            };

            UsersListVM.ApplicationUserList = UsersListVM.ApplicationUserList.OrderBy(p => p.Email)
                                              .Skip((productPage - 1) * SD.PaginationUsersPageSize)
                                              .Take(SD.PaginationUsersPageSize).ToList();

            return(Page());
        }
        public IActionResult List()
        {
            UsersListViewModel model = new UsersListViewModel();

            model.Users = usersService.GetAll();

            return(View(model));
        }
Esempio n. 23
0
 public void InitTest()
 {
     _userService     = A.Fake <IUserService>();
     _eventAggregator = A.Fake <IEventAggregator>();
     _view            = A.Fake <IUsersListView>();
     _containter      = A.Fake <IUnityContainer>();
     _viewModel       = new UsersListViewModel(_userService, _eventAggregator, _view, _containter);
 }
 public AddTaskUserPage(TasksViewModel taskToAdd)
 {
     InitializeComponent();
     this.task           = taskToAdd;
     users_list          = new UsersListViewModel(new Users());
     users_list.task_id  = this.task.id;
     this.BindingContext = users_list;
 }
Esempio n. 25
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            teamuserlist = new UsersListViewModel();
        }
Esempio n. 26
0
        public UsersListPage()
        {
            InitializeComponent();

            BindingContext = new UsersListViewModel {
                Navigation = this.Navigation
            };
        }
Esempio n. 27
0
        public IActionResult Dialogues()
        {
            UsersListViewModel viewModel = new UsersListViewModel {
                FRiends = _manager.GetFriends(User.Identity.Name),
            };

            return(View(viewModel));
        }
Esempio n. 28
0
        public ActionResult Index()
        {
            var model = new UsersListViewModel {
                Users = AutoMapper.Mapper.Map <IList <RedfernUser>, IList <UserListItem> >(UserManager.Users.Where(u => u.TenantId == _context.TenantID).ToList())
            };

            return(PartialView("_index", model));
        }
Esempio n. 29
0
        public IActionResult Index()
        {
            var vm = new UsersListViewModel
            {
                Users = _userService.GetAll()
            };

            return(View(vm));
        }
        public async Task <IViewComponentResult> InvokeAsync(UsersListViewModel viewModel)
        {
            if (viewModel == null)
            {
                viewModel = new UsersListViewModel();
            }

            return(View(viewModel));
        }
Esempio n. 31
0
 public ActionResult Login(UsersListViewModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (repository.ValidateUser(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
             if (Url.IsLocalUrl(returnUrl))
             {
                 return Redirect(returnUrl);
             }
             else
             {
                 return RedirectToAction("Index", "Admin");
             }
         }
         else
         {
             ModelState.AddModelError("", "Неправильный пароль или логин");
         }
     }
     return View();
 }