Beispiel #1
0
        public ActionResult EditInfo(IndividualSender msg)
        {
            //Edit personal information and submit changes
            USERS present_user = db.USERS.Find(Convert.ToInt16(Session["user_id"]));

            if (msg.name != "")
            {
                present_user.NAME = msg.name;
            }
            if (msg.gender == "男")
            {
                present_user.GENDER = "male";
            }
            else if (msg.gender == "女")
            {
                present_user.GENDER = "female";
            }
            if (msg.name != "")
            {
                present_user.EMAIL = msg.email;
            }
            db.SaveChanges();

            return(Redirect("~/Individual"));
        }
Beispiel #2
0
        public ActionResult EditPassword(IndividualSender msg)
        {
            //Edit password with encryption and submit changes
            USERS present_user = db.USERS.Find(Convert.ToInt16(Session["user_id"]));

            byte[] bytes           = Convert.FromBase64String(present_user.PASSWORD);
            var    decode_password = Encoding.UTF8.GetString(bytes);

            if (decode_password == msg.ex_password)
            {
                byte[] new_bytes = Encoding.UTF8.GetBytes(msg.new_password);
                present_user.PASSWORD = Convert.ToBase64String(new_bytes);
                db.SaveChanges();
            }
            else
            {
                ViewBag.Error = "Wrong password!";
            }

            return(Redirect("~/Individual"));
        }