Esempio n. 1
0
        public bool UserExists(AddUserModel user)
        {
            if (!Find.Element(By.CssSelector("tr:last-of-type td.username")).Text.Equals(user.Username))
                return false;

            if (!Find.Element(By.CssSelector("tr:last-of-type td.role")).Text.Equals(user.Role.Humanize()))
                return false;

            if (!Find.Element(By.CssSelector("tr:last-of-type td.firstname")).Text.Equals(user.FirstName))
                return false;

            if (!Find.Element(By.CssSelector("tr:last-of-type td.lastname")).Text.Equals(user.LastName))
                return false;

            if (!Find.Element(By.CssSelector("tr:last-of-type td.staffusi")).Text.Equals(user.StaffUSI.ToString()))
                return false;

            return true;

        }
Esempio n. 2
0
        public virtual ActionResult AddUser(AddUserModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var staff = _addUserModelToStaffMapper.Build(model);
            _genericRepository.Add(staff);
            _genericRepository.Save();

            var user = _addUserModelToApplicationUserMapper.Build(model);
            var result = _userManager.Create(user, model.Password);
            if (result.Succeeded)
            {
                _userManager.AddToRole(user.Id, model.Role.Humanize());
                return RedirectToAction("Users");
            }

            AddErrors(result);

            return View(model);
        }