예제 #1
0
        public ActionResult UpdateProfile(User user)
        {
            if (user == null || Session["User"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            string result = string.Empty;

            if (string.IsNullOrEmpty(user.FirstName))
            {
                result = "Error";
            }
            if (string.IsNullOrEmpty(user.LastName))
            {
                result = "Error";
            }
            if (string.IsNullOrEmpty(user.Phone))
            {
                result = "Error";
            }

            if (string.IsNullOrEmpty(result))
            {
                var sUser = (User)Session["User"];
                result          = db.UpdateUser(sUser.ID, user.FirstName, user.LastName, user.Phone);
                Session["User"] = db.GetUser(sUser.Email, sUser.Password);
            }

            ViewBag.Result = result == "Success" ? 1 : 2;
            ViewBag.User   = Session["User"];
            return(View("UserProfile"));
        }