Ejemplo n.º 1
0
 public ActionResult EditUser(ProfileViewModel user)
 {
     if (ModelState.IsValid)
     {
         using (UsersContext context = new UsersContext())
         {
             var user2 = context.GetUser(User.Identity.Name);
             if (context.GetUsers().Any(m => m.login == user.login && m.id != user.id))
             {
                 ViewBag.ErrorMessage = "Taki login już istnieje";
             }
             else
             {
                 user.id = user2.id;
                 profileModel.EditProfile(user);
             }
         }
     }
     UserModel model = new UserModel()
     {
         PasswordModel = new LocalPasswordModel(),
         ProfileModel = user
     };
     return View("Manage", model);
 }
Ejemplo n.º 2
0
        public ActionResult Manage(LocalPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                using (UsersContext context = new UsersContext())
                {
                    var user = context.GetUser(User.Identity.Name);
                    if (user.password == model.OldPassword)
                    {
                        if (model.NewPassword == model.ConfirmPassword)
                        {
                            user.password = model.NewPassword;
                            context.SaveUser(user);
                            ViewBag.StatusMessage = "Zmiana hasła powiodła się!";
                            return RedirectToAction("Manage");

                        }
                        else
                        {
                            ViewBag.ErrorMessage = "Nowe hasło i powtórzone nie są identyczne!";
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Stare hasło jest niepoprawne";
                    }
                }
            }

            UserModel uzytkownikModel = new UserModel()
            {
                PasswordModel = model,
                ProfileModel = CreateProfileModel()
            };

            var uzytkownik = this.profileModel.GetProfile(User.Identity.Name);
            ViewBag.ReturnUrl = Url.Action("Manage");
            return View(uzytkownikModel);
        }
Ejemplo n.º 3
0
        //
        // GET: /Account/Manage
        public ActionResult Manage(ManageMessageId? message)
        {
            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."
                : "";
            UserModel model = new UserModel()
            {
                PasswordModel = new LocalPasswordModel(),
                ProfileModel = CreateProfileModel()
            };

            var uzytkownik = profileModel.GetProfile(User.Identity.Name);
            ViewBag.ReturnUrl = Url.Action("Manage");
            return View(model);
        }