public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            bool hasPassword = HasPassword();
            ViewBag.HasLocalPassword = hasPassword;
            ViewBag.ReturnUrl = Url.Action("Manage");
            if (hasPassword)
            {
                if (ModelState.IsValid)
                {
                    IdentityResult result =
                        await
                            UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword,
                                model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                    }
                    AddErrors(result);
                }
            }
            else
            {
                // User does not have a password so remove any validation errors caused by a missing OldPassword field
                ModelState state = ModelState["OldPassword"];
                if (state != null)
                {
                    state.Errors.Clear();
                }

                if (ModelState.IsValid)
                {
                    IdentityResult result =
                        await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                    if (result.Succeeded)
                    {
                        return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                    }
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        //
        // GET: /Account/Manage
        public ActionResult Manage(ManageMessageId? message)
        {
            string userId = User.Identity.GetUserId();
            ApplicationUser applicationuser = _accountService.Get(userId);

            if (applicationuser != null)
            {
                var manageUserViewModel = new ManageUserViewModel
                                          {
                                              Address = applicationuser.Address,
                                              Email = applicationuser.Email,
                                              FirstName = applicationuser.FirstName,
                                              City = applicationuser.City,
                                              LastName = applicationuser.LastName,
                                              Phone = applicationuser.Phone,
                                              PostalCode = applicationuser.PostalCode,
                                              Province = applicationuser.Province,
                                              UserName = applicationuser.UserName
                                          };

                ViewBag.StatusMessage =
                    message == ManageMessageId.ChangePasswordSuccess
                        ? "Your password has been changed."
                        : message == ManageMessageId.SetPasswordSuccess
                            ? "Your password has been set."
                            : message == ManageMessageId.RemoveLoginSuccess
                                ? "The external login was removed."
                                : message == ManageMessageId.Error
                                    ? "An error has occurred."
                                    : "";
                ViewBag.HasLocalPassword = HasPassword();
                ViewBag.ReturnUrl = Url.Action("Manage");
                return View(manageUserViewModel);
            }

            return RedirectToAction("Login");
        }