Ejemplo n.º 1
0
 public void Post_valid_profile_redirect_user_to_dashboard()
 {
     security.ReturnUser = new User();
     var model = new MyProfileModel();
     var view = userController.MyProfile(model) as RedirectToRouteResult;
     Assert.IsNotNull(view);
     Assert.AreEqual("Index", view.RouteValues["action"]);
 }
Ejemplo n.º 2
0
        public ActionResult MyProfile()
        {
            if (!_securityService.IsLoggedIn())
            {
                return RedirectToAction("Checkpoint", "Security", new { returnUrl = Url.Action("MyProfile") });
            }

            var model = new MyProfileModel(_securityService.GetCurrentUser(), _teamRepository.GetTeams());
            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult MyProfile(MyProfileModel model)
        {
            if (!_securityService.IsLoggedIn())
            {
                return RedirectToAction("Checkpoint", "Security", new { returnUrl = Url.Action("MyProfile") });
            }

            if (ModelState.IsValid)
            {
                var user = _securityService.GetCurrentUser();
                user.Cellphone = model.Cellphone;
                user.Name = model.Name;
                user.Team = model.Team;

                _userRepository.Save(user);

                return RedirectToAction("Index", "Home");
            }

            var viewModel = new MyProfileModel(model.ToUser(), _teamRepository.GetTeams());
            return View(viewModel);
        }