public ActionResult UserDetails(UserDetailsViewModel viewModel)
        {
            if (!ModelState.IsValid)
                return View(viewModel);
            var profile = ProfileService.GetUserProfile(viewModel.User.ID);
            profile.Balance = viewModel.UserProfile.Balance;
            ProfileService.Save();

            return RedirectToAction("Users", new {id = 0});
        }
 public ViewResult UserDetails(int id)
 {
     var user = MembershipService.GetUser(id);
     var userProfile = ProfileService.GetUserProfile(user);
     var viewModel = new UserDetailsViewModel
                     {
                         User = user,
                         UserProfile = userProfile
                     };
     return View(viewModel);
 }
        public void UserDetailsPost_ModelStateIsValid_RedirectedToUserList()
        {
            // Arrange
            var profile = new UserProfile();
            var viewModel = new UserDetailsViewModel { UserProfile = profile };
            var profileService = new Mock<IProfileService>();
            var controller = new AdminController(null, profileService.Object);

            // Act
            var result = controller.UserDetails(viewModel);

            // Assert
            var viewResult = (ViewResult)result ;
            viewResult.ViewName.Should().Be("Users");
        }
        public void UserDetailsPost_ModelStateIsNotValid_FormReshown()
        {
            // Arrange
            var viewModel = new UserDetailsViewModel {UserProfile = new UserProfile(), User = new User()};
            var profileService = new Mock<IProfileService>();
            var controller = new AdminController(null, profileService.Object);
            controller.ModelState.AddModelError("","");

            // Act
            var result = controller.UserDetails(viewModel);

            // Assert
            var viewResult = (ViewResult)result;
            viewResult.ViewName.Should().Be("");
        }