public ActionResult Admin() { UsersListsVM usersListsVM = new UsersListsVM(); IList <User> uslist1 = (IList <User>)_userRepository.GetNotActiveYet().OrderBy(t => t.FirstName).ToList(); IList <User> uslist2 = (IList <User>)_userRepository.GetWasActivated().OrderBy(t => t.FirstName).ToList(); usersListsVM.NoActiveUsers = Mapper.Map <IList <User>, IList <UserVM> >(uslist1); usersListsVM.AllUsers = Mapper.Map <IList <User>, IList <UserVM> >(uslist2); return(View(MVCManager.Controller.Home.Admin, usersListsVM)); }
public ActionResult Admin(UsersListsVM usersLists) { foreach (var userVM in usersLists.AllUsers) { var user = _userRepository.Get(userVM.Id); user.IsActive = userVM.IsActive; user.IsAdmin = userVM.IsAdmin; user.IsUploader = userVM.IsUploader; } _userRepository.UnitOfWork.SaveChanges(); ICollection <User> users = _userRepository.GetAll().ToList(); ICollection <UserVM> newUsersVM = Mapper.Map <ICollection <User>, ICollection <UserVM> >(users); return(RedirectToAction(MVCManager.Controller.Home.Admin, newUsersVM)); }