public void UserNameShouldHaveErrorWhenInUse()
        {
            _userService.Setup(x => x.UserNameAvailable(It.IsAny<int>(), It.IsAny<string>())).Returns(false);

            var form = new AdminUserForm();
            var result = _validator.Validate(form);
            result.ShouldHaveError<AdminUserForm>(x => x.UserName, "User name is in use");
        }
Пример #2
0
        public ActionResult Edit(AdminUserForm form)
        {
            if (ModelState.IsValid)
            {
                var user = _userService.Get(form.Id);
                Mapper.Map(form, user);

                _userService.Update(user);
                return RedirectToAction("Index");
            }

            form.RoleList = GetRoleList();
            return View(form);
        }