Exemplo n.º 1
0
        public ActionResult ChangeProfile(FormChangeUser u)
        {
            User user = (User)Session[KeysUtils.SessionUser()];

            if (!user.email.Trim().Equals(u.email) && Models.User.EmailExists(u.email))
            {
                ModelState.AddModelError("EmailExists", "Email already exists");
            }
            else
            {
                if (u.password == null || u.password.Trim().Equals(""))
                {
                    u.password = ((User)(Session[KeysUtils.SessionUser()])).password;
                }
                else
                {
                    user.password = CryptUtils.Hash(u.password);
                }
                user.email      = u.email;
                user.first_name = u.firstName;
                user.last_name  = u.lastName;
                user.saveChanges();
                Session[KeysUtils.SessionUser()] = user;
                ViewBag.Status  = true;
                ViewBag.Message = "Changed profile  successfully";
            }



            return(View(u));
        }
Exemplo n.º 2
0
        public ActionResult ChangeProfile()
        {
            User u = (User)Session[KeysUtils.SessionUser()];

            if (u == null)
            {
                return(RedirectToAction("Register", "Home"));
            }
            else
            {
                FormChangeUser fcu = new FormChangeUser();
                fcu.lastName  = u.last_name.Trim();
                fcu.firstName = u.first_name.Trim();
                fcu.email     = u.email;
                fcu.password  = "";

                return(View(fcu));
            }
        }