public void verifyThatAfterCorrectingPropertiesAndUserValidNoErrorMessagesExist() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; target.AddUser(); Assert.AreEqual(1, target.Users.Count, "Should have addded the user"); //Test User - Fail target.Username = "******"; target.Password = "******"; target.IsUserValid(); Assert.IsFalse(target.IsAuthenticated, "User should be invalid"); Assert.IsFalse(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should be an error message"); //Test User - Pass target.Username = "******"; target.Password = "******"; target.IsUserValid(); Assert.IsTrue(target.IsAuthenticated, "User should be valid"); Assert.IsTrue(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should not be an error message"); }
public async Task <IActionResult> UserManager(string keySearch, int page = 1, int pageSize = 5) { if (string.IsNullOrWhiteSpace(keySearch)) { keySearch = string.Empty; } //var user = await userManager.GetUserAsync(User); List <User> users = new List <User>(); users = userService.AllUser(keySearch); // List <UserBasicViewModel> listUser = new List <UserBasicViewModel>(); foreach (var u in users) { // Get roles of user List <string> roles = new List <string>(await userManager.GetRolesAsync(u)); UserBasicViewModel user = new UserBasicViewModel() { ID = u.Id, HoTen = u.HoTen, Email = u.Email, PhoneNumber = u.PhoneNumber, Roles = roles, State = u.State }; listUser.Add(user); } UserManagerViewModel model = new UserManagerViewModel(listUser, page, pageSize, keySearch); return(View(model)); }
public IActionResult Index(UserManagerViewModel model) { ViewData["Message"] = "Your registration page!."; ViewBag.SuccessMessage = null; if (ModelState.IsValid) { try { // Find your Account Sid and Auth Token at twilio.com/user/account var acctSid = Configuration["Twilio:AccountSid"]; var authT = Configuration["Twilio:AuthToken"]; TwilioClient.Init(acctSid, authT); var to = new PhoneNumber("+1" + model.PhoneNumber); var message = MessageResource.Create( to, from: new PhoneNumber(Configuration["Twilio:ToNumber"]), // From number, must be an SMS-enabled Twilio number ( This will send sms from ur "To" numbers ). body: $"Hello {model.Name} {model.Text}"); ViewBag.SuccessMessage = "Registered Successfully !!"; } catch (Exception ex) { Console.WriteLine($" Registration Failure : {ex.Message} "); } } ModelState.Clear(); return(RedirectToAction("Index")); }
public void verifyUsernameIsInvalid() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; target.AddUser(); Assert.AreEqual(1, target.Users.Count, "Should have addded the user"); //User is clear Assert.IsTrue(String.IsNullOrEmpty(target.Username)); Assert.IsTrue(String.IsNullOrEmpty(target.Password)); Assert.IsTrue(String.IsNullOrEmpty(target.Realname)); //Test User target.Username = "******"; target.Password = "******"; target.IsUserValid(); Assert.IsFalse(target.IsAuthenticated, "User should be invalid"); Assert.IsFalse(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should be an error message"); }
public HttpResponseMessage GetUser(string id) { var user = new UserManagerViewModel(); user = _userManagerViewService.GetUser(id); return(Request.CreateResponse(HttpStatusCode.OK, user, MediaTypeHeaderValue.Parse("application/json"))); }
public ActionResult Index(UserManagerViewModel usersViewModel) { UserRepository userRepository = new UserRepository(); userRepository.ModifyUsers(usersViewModel.Users); return(RedirectToAction("Index")); }
// GET: User public ActionResult Index() { UserManagerViewModel userViewModel = new UserManagerViewModel(); userViewModel.Users = new UserRepository().GetAllUsers(); return(View(userViewModel)); }
public async Task <IActionResult> Index() { var allUsers = await _userManager.Users.ToListAsync(); var vm = new List <UserManagerViewModel>(); foreach (ApplicationUser user in allUsers) { string userId = user.Id; var thisvm = new UserManagerViewModel(); thisvm.UserId = user.Id; thisvm.UserName = user.UserName; thisvm.Email = user.Email; thisvm.IsBanned = user.IsBanned; thisvm.SignUpDate = user.SignUpDate; thisvm.UserPortfolioItemMainComments = _repo.GetAllPortfolioItemMainComments(userId); thisvm.UserPortfolioItemSubComments = _repo.GetAllPortfolioItemSubComments(userId); thisvm.UserPostMainComments = _repo.GetAllPostMainComments(userId); thisvm.UserPostSubComments = _repo.GetAllPostSubComments(userId); vm.Add(thisvm); } return(View(vm)); }
/// <summary> /// Generates the user manager page /// </summary> /// <returns> /// Returns the user manager view /// </returns> public ActionResult ManageUsers() { var Model = new UserManagerViewModel(); Model.users = UserManager.Users.ToList(); Model.roles = RoleManager.Roles.ToList(); return(View(Model)); }
public BatchRecord(ICarPortAppService carPortAppService, MainWindowViewModel mainWindowViewModel, UserManagerViewModel userManagerViewModel, CarPortListDto carPortListDto) { InitializeComponent(); _carPortListDto = carPortListDto; _carPortAppService = carPortAppService; _mainWindowViewModel = mainWindowViewModel; _userManagerViewModel = userManagerViewModel; }
public HttpResponseMessage GetUsers() { var context = _contextService.GetContext(); var userManager = new UserManagerViewModel(); userManager = _userManagerViewService.GetUsers(context); return(Request.CreateResponse(HttpStatusCode.OK, userManager, MediaTypeHeaderValue.Parse("application/json"))); }
public UserManagementWindow() { InitializeComponent(); _ConsoleViewModel.InitializeViewModelData(); _UserManagerViewModel = new UserManagerViewModel(_ConsoleViewModel.HolderData.RegisteredEmployees); this.DataContext = _UserManagerViewModel; }
public CarportInfo(ICarPortAppService carPortAppService, MainWindowViewModel mainWindowViewModel, UserManagerViewModel userManagerViewModel, CarPortListDto carPortListDto) { InitializeComponent(); _carPortListDto = carPortListDto; _carPortAppService = carPortAppService; _mainWindowViewModel = mainWindowViewModel; _userManagerViewModel = userManagerViewModel; _carPortTimeExTenstionViewModel = new CarPortTimeExTenstionViewModel(); }
public void checkNotifyPropertyChangedUserName() { User user = new User(); UserManagerViewModel target = new UserManagerViewModel(user, null, null); bool eventWasRaised = false; target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "Username"; target.Username = "******"; Assert.IsTrue(eventWasRaised, "Event for username change should have been raised"); }
public CarPortTimeExtension(ICarPortAppService carPortAppService, MainWindowViewModel mainWindowViewModel, UserManagerViewModel userManagerViewModel, CarPortListDto carPortListDto) { InitializeComponent(); _carPortAppService = carPortAppService; _mainWindowViewModel = mainWindowViewModel; _userManagerViewModel = userManagerViewModel; _carPortTimeExTenstionViewModel = new CarPortTimeExTenstionViewModel(); _carPortTimeExTenstionViewModel.CarPortListDto = carPortListDto; DataContext = _carPortTimeExTenstionViewModel; _rechargeRecordAppService = IocManager.Resolve <IRechargeRecordAppService>(); }
public ActionResult UserManager() { UserManagerViewModel m = new UserManagerViewModel(); m.users = _dbhelper.GetUsers().ToList(); m.currentuser = _dbhelper.GetUserById(new WritaUser() { Id = User.Identity.Name }); m.posts = _dbhelper.GetAllPosts().ToList(); return(View("~/Views/Admin/UserManager.cshtml", "~/Views/Admin/_Adminlayout.cshtml", m)); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow window = new MainWindow(); User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasher = new HmacSha512Hasher(); var viewModel = new UserManagerViewModel(user, repo, hasher); window.DataContext = viewModel; window.Show(); }
public async Task <IActionResult> Edit(string id) { ApplicationUser user = await userManager.FindByIdAsync(id); if (user != null) { UserManagerViewModel model = new UserManagerViewModel { Email = user.Email, Id = user.Id, AllRoles = roleManager.Roles.ToList(), Roles = await userManager.GetRolesAsync(user) }; return(View(model)); } return(NotFound()); }
public AddCarNumber(UserManagerViewModel userManagerViewModel, ICarNumbersAppService carNumbersAppService) { InitializeComponent(); _userManagerViewModel = userManagerViewModel; carNumbersListDto = new CarNumbersListDto(); _carNumbersAppService = carNumbersAppService; if (_userManagerViewModel.SelectDto != null) { carNumbersListDto.Phone = _userManagerViewModel.SelectDto.Phone; carNumbersListDto.Contact = _userManagerViewModel.SelectDto.Contact; carNumbersListDto.Remark = _userManagerViewModel.SelectDto.Remark; } }
public void addUserThroughCommandAddUser() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; target.AddUserCommand.Execute(null); Assert.AreEqual(1, target.Users.Count, "Should have addded the user"); }
public ActionResult Save(UserManagerViewModel newUserData) { if (!ModelState.IsValid) { return(View("UserManagerForm", newUserData)); } var applicationUser = _userManager.FindById(newUserData.Id); if (applicationUser == null) { return(View("UserManagerForm", newUserData)); } _userManager.RemoveFromRoles(applicationUser.Id, _userManager.GetRoles(applicationUser.Id).ToArray()); if (newUserData.UserRoleIds != null) { var userRoleNames = newUserData.UserRoleIds .Select(r => _roleManager.FindById(r).Name) .ToArray(); foreach (var roleName in userRoleNames) { if (!_roleManager.RoleExists(roleName)) { return(View("UserManagerForm", newUserData)); } } _userManager.AddToRoles(applicationUser.Id, userRoleNames); } _userManager.Update(applicationUser); var currentApplicationUser = _userManager.FindById(User.Identity.GetUserId()); var authenticationManager = System.Web.HttpContext.Current.GetOwinContext().Authentication; authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var identity = _userManager.CreateIdentity(currentApplicationUser, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = false }, identity); return(RedirectToAction("Index")); }
public void addingNewUserUserHashingFunction() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; target.AddUser(); Assert.IsTrue(hasherAlgorithm.VerifyHash("teste", target.Users[0].Password, "mige")); }
public void verifyThatAfterAddingUserUIisCleared() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; target.AddUser(); Assert.IsTrue(String.IsNullOrEmpty(target.Username)); Assert.IsTrue(String.IsNullOrEmpty(target.Password)); Assert.IsTrue(String.IsNullOrEmpty(target.Realname)); }
public async Task <IActionResult> Index() { var admins = (await _userManager .GetUsersInRoleAsync("Administrator")) .ToArray(); var everyone = await _userManager.Users .ToArrayAsync(); var model = new UserManagerViewModel { Administrators = admins, Everyone = everyone }; return(View(model)); }
public void verifyThatAddingUserWithErrorsFails() { User user = new User(); UserRepository repo = new UserRepository(); PasswordHasher hasherAlgorithm = new HmacSha512Hasher(); UserManagerViewModel target = new UserManagerViewModel(user, repo, hasherAlgorithm); target.Username = "******"; target.Password = "******"; target.Realname = "Mig"; string error = (target as IDataErrorInfo)["Username"]; Assert.IsFalse(String.IsNullOrEmpty(error), "Should have received error message"); target.AddUser(); Assert.AreEqual(0, target.Users.Count, "Should have not addded the user"); }
public UserManager(MainWindowViewModel mainWindowViewModel, ICarUsersAppService carUsersAppService, IParkAreasAppService parkAreasAppService, ICarUserGroupAppService carUserGroupAppService, ICarNumbersAppService carNumbersAppService, ICarPortAppService carPortAppService ) { InitializeComponent(); _mainWindowViewModel = mainWindowViewModel; _carUsersAppService = carUsersAppService; _parkAreasAppService = parkAreasAppService; _carUserGroupAppService = carUserGroupAppService; _carNumbersAppService = carNumbersAppService; _carPortAppService = carPortAppService; _managerViewModel = new UserManagerViewModel(); DataContext = _managerViewModel; }
public async Task <IActionResult> UserManager() { var users = _userManager.Users.ToList(); var model = new UserManagerViewModel(); foreach (var user in users) { var roles = await _userManager.GetRolesAsync(user); var item = new UserRoleViewModel { Roles = roles, User = user }; model.Users.Add(item); } return(View(model)); }
public App() { LogonViewModel = new LogonViewModel(); MainPageViewModel = new MainPageViewModel(); LogonUserViewModel = new LogonUserViewModel(); UserManagerViewModel = new UserManagerViewModel(); FileTypeManagerViewModel = new FileTypeManagerViewModel(); TaxPayerTypeManagerViewModel = new TaxPayerTypeManagerViewModel(); TaxPayerManagerViewModel = new TaxPayerManagerViewModel(); DocumentManagerViewModel = new DocumentManagerViewModel(); this.Startup += this.Application_Startup; this.UnhandledException += this.Application_UnhandledException; this.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted); InitializeComponent(); WebContext webContext = new WebContext(); webContext.Authentication = new FormsAuthentication(); this.ApplicationLifetimeObjects.Add(webContext); }
// GET: UserManager/Edit public ActionResult Edit(string userId) { var user = _context.Users .SingleOrDefault(u => u.Id == userId); if (user == null) { return(HttpNotFound()); } var userManagerViewModel = new UserManagerViewModel() { Id = user.Id, Email = user.Email, UserRoleIds = GetRolesByUserId(user.Id).Select(r => r.Id).ToList(), Roles = _roles }; return(View("UserManagerForm", userManagerViewModel)); }
public UserManagerViewModel GetUser(string idUser) { var result = new UserManagerViewModel(); Guid userId; if (Guid.TryParse(idUser, out userId)) { //user var userModel = _userManagerService.GetUser(userId); var user = new UserViewModel(); user.ID = userModel.ID; user.Username = userModel.Username; user.FirstName = userModel.FirstName; user.LastName = userModel.LastName; user.Email = userModel.Email; user.CustomerName = userModel.CustomerName; user.RoleCode = (int)userModel.Role; user.RoleName = userModel.Role.GetDescription(); user.LanguageId = userModel.Language.ID; user.LanguageName = userModel.Language.Name; user.Enabled = userModel.Enabled; user.Machines = userModel.Machines.Select(s => new UserMachineViewModel { Id = s.Id, Serial = s.Serial }).ToList(); user.TimeZone = userModel.TimeZone; result.user = user; //machines for customer result.machines = GetMachinesByCustomer(userModel.CustomerName); return(result); } else { return(null); } }