Esempio n. 1
0
        public async Task<ActionResult> ChangePrivacy(ChangePrivacyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            //Get the old user so we have the fields for it, then update the privacy setting and save to the DB
            var newUser = UserManager.FindById(User.Identity.GetUserId());
            newUser.Private = model.NewIsPrivate;
            var result = await UserManager.UpdateAsync(newUser);

            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                if (user != null)
                {
                    await SignInAsync(user, isPersistent: false);
                }
                return RedirectToAction("Index", new { Message = ManageMessageId.ChangePrivacySuccess });
            }
            AddErrors(result);
            return View(model);
        }
Esempio n. 2
0
 //
 // GET: /Manage/ChangePrivacy
 public ActionResult ChangePrivacy()
 {
     var userId = User.Identity.GetUserId();
     var model = new ChangePrivacyViewModel
     {
         CurrentIsPrivate = UserManager.FindById(User.Identity.GetUserId()).Private,
         NewIsPrivate = UserManager.FindById(User.Identity.GetUserId()).Private
     };
     return View(model);
 }