public UserEditViewModel Display(UserEditViewModel userEditViewModel) { User user = _userRepository.GetUser(userEditViewModel.UserId); return new UserEditViewModel(user) { Message = userEditViewModel.IsAjaxRequest() ? "Json Result" : "View Result" }; }
public void Should_map_UserAddEditViewModel_to_User_with_DateOfBirth_set_to_null() { _userEditModel = new UserEditViewModel(_user); User actualUser = _mapper.MapFrom(_userEditModel); Assert.AreEqual(_user.UserId, actualUser.UserId); Assert.AreEqual(_user.LastName, actualUser.LastName); Assert.AreEqual(_user.FirstName, actualUser.FirstName); Assert.IsNull(actualUser.DateOfBirth); }
public void Should_map_UserAddEditViewModel_to_User() { _user.DateOfBirth = Convert.ToDateTime("12/12/1990"); _userEditModel = new UserEditViewModel(_user); User actualUser = _mapper.MapFrom(_userEditModel); Assert.AreEqual(_user.UserId, actualUser.UserId); Assert.AreEqual(_user.LastName, actualUser.LastName); Assert.AreEqual(_user.FirstName, actualUser.FirstName); Assert.AreEqual(_user.DateOfBirth, actualUser.DateOfBirth); }
public UserListViewModel Delete(UserEditViewModel userEditViewModel) { User user = _mapper.MapFrom(userEditViewModel); string message; try { _userRepository.Delete(user); message = String.Format("User {0} successfully deleted", user.UserId); } catch (ArgumentException exception) { message = String.Format("User {0} could not be deleted: {1}", user.UserId, exception.Message); } UserListViewModel usersListViewModel = GetUsers(); usersListViewModel.Message = message; return usersListViewModel; }
public void SetUp() { _mocker = new RhinoAutoMocker<UserController>(); _userRepository = _mocker.Get<IUserRepository>(); _userMapper = _mocker.Get<IMapper<UserEditViewModel, User>>(); _userController = _mocker.ClassUnderTest; const string userId = "Test"; _userEditModel = new UserEditViewModel { UserId = userId }; _user = new User { UserId = userId }; }
public UserIndexViewModel Cancel(UserEditViewModel userEditViewModel) { _resultOverride.RedirectTo(_urlResolver.UrlFor <UserController>()); return(new UserIndexViewModel()); }
public UserEditViewModel Edit(UserEditViewModel userEditViewModel) { User user = _userRepository.GetUser(userEditViewModel.UserId); return(new UserEditViewModel(user)); }
public UserEditViewModel New(UserEditViewModel userEditViewModel) { return(new UserEditViewModel()); }
public UserEditViewModel Save(UserEditViewModel userEditViewModel) { if (String.IsNullOrEmpty(userEditViewModel.UserId)) { userEditViewModel.Message = String.Format("UserId cannot be blank"); return userEditViewModel; } User user = _mapper.MapFrom(userEditViewModel); try { _userRepository.Save(user); userEditViewModel.Message = "User saved successfully"; } catch (Exception exception) { userEditViewModel.Message = String.Format("User could not be saved: {0}", exception.Message); } return userEditViewModel; }
public UserEditViewModel New(UserEditViewModel userEditViewModel) { return new UserEditViewModel(); }
public UserEditViewModel Edit(UserEditViewModel userEditViewModel) { User user = _userRepository.GetUser(userEditViewModel.UserId); return new UserEditViewModel(user); }
public UserIndexViewModel Cancel(UserEditViewModel userEditViewModel) { _resultOverride.RedirectTo(_urlResolver.UrlFor<UserController>()); return new UserIndexViewModel(); }
public void SetUp() { _mocker = new RhinoAutoMocker<UserController>(); _userController = _mocker.ClassUnderTest; _userEditModel = new UserEditViewModel(); }
public void Should_display_error_message_if_UserId_is_blank() { _userEditModel = new UserEditViewModel(); _userRepository.Expect(x => x.Save(null)).IgnoreArguments(); UserEditViewModel userDisplayModel = _userController.Save(_userEditModel); Assert.IsNotNull(userDisplayModel); Assert.AreEqual("UserId cannot be blank", userDisplayModel.Message); }
public void SetUp() { _mocker = new RhinoAutoMocker<UserController>(); _userRepository = _mocker.Get<IUserRepository>(); _userController = _mocker.ClassUnderTest; _userEditModel = new UserEditViewModel { UserId = "Id" }; }
public void SetUp() { _mocker = new RhinoAutoMocker<UserController>(); _userRepository = _mocker.Get<IUserRepository>(); _userController = _mocker.ClassUnderTest; _user = new User { UserId = "Id", LastName = "LName", FirstName = "FName" }; _userEditModel = new UserEditViewModel(); }