Пример #1
0
        public ActionResult ChangeUser(FormCollection frmCollection, string submitButton)
        {
            int          ID        = Convert.ToInt32(frmCollection["UsrID"]);
            User         usr       = new User();
            UsersHandler usrHandlr = new UsersHandler();

            usr = usrHandlr.GetUserDetails(ID);
            if (submitButton == "Save")
            {
                string pwd   = frmCollection["pwdVal"];
                string email = frmCollection["Email"];
                if (!(string.IsNullOrEmpty(pwd)))
                {
                    pwd = Encryptor.MD5Hash(pwd);
                }
                if (!(string.IsNullOrEmpty(pwd)))
                {
                    usr.Password = pwd;
                }
                usr.Email = email;
                usrHandlr.UpdateUser(usr);
                return(RedirectToAction("Home", "UserHome", usr));
            }
            else if (submitButton == "Exit from Application")
            {
                usrHandlr.RemoveUser(Convert.ToInt32(frmCollection["UsrID"]));
                return(RedirectToAction("Login", "TCLogin"));
            }
            return(RedirectToAction("Home", "UserHome", usr));
        }