public ActionResult Manage()
 {
     var userProfile = accountService.GetUser(User.Identity.Name);
     var model = new PasswordModel
         {
             ChangePassword = true,
             Email = userProfile.Email,
             FirstName = userProfile.FirstName,
             LastName = userProfile.LastName,
         };
     return View(model);
 }
        public ActionResult Manage(PasswordModel model)
        {
            ViewBag.ReturnUrl = Url.Action("Manage");

            if (ModelState.IsValid)
            {
                var username = User.Identity.Name;
                var userProfile = new UserProfile
                    {
                        Email = model.Email,
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        UserId = WebSecurity.GetUserId(username),
                        UserName = username
                    };
                accountService.UpsertUserProfile(userProfile);

                // ChangePassword will throw an exception rather than return false in certain failure scenarios.
                if (model.ChangePassword)
                {
                    try
                    {
                        if (WebSecurity.Login(username, model.OldPassword))
                        {
                            WebSecurity.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword);
                        }
                        else
                        {
                            ModelState.AddModelError("", resources.GetString("Manage_PasswordChangeFailed"));
                        }
                    }
                    catch (Exception)
                    {
                        ModelState.AddModelError("", resources.GetString("Manage_PasswordChangeFailed"));
                    }
                }

                ViewBag.StatusMessage = ModelState.IsValid
                                            ? resources.GetString("Manage_Succeeded")
                                            : resources.GetString("Manage_Failed");
            }
            return View(model);
        }