Example #1
0
        /// <summary>
        /// 用户爱好请求
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateUserCardRequest(int id, String taste, String fruit, String vegetables, String dishes)
        {
            if (id > 0)
            {
                ucard uc = db.ucard.SingleOrDefault <ucard>(u => u.id == id);

                if (taste.Length > 0)
                {
                    uc.taste = taste;
                }

                if (fruit.Length > 0)
                {
                    uc.fruit = fruit;
                }

                if (vegetables.Length > 0)
                {
                    uc.vegetables = vegetables;
                }

                if (dishes.Length > 0)
                {
                    uc.dishes = dishes;
                }

                int row = db.SaveChanges();
                if (row > 0)
                {
                    Response.Redirect("/user/index");
                }
            }

            return(View());
        }
Example #2
0
        /// <summary>
        /// 用户编辑爱好
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateUserCard()
        {
            user_table user = checkUser();
            ucard      uca  = db.ucard.SingleOrDefault <ucard>(uc => uc.uid == user.id);

            ViewData["ucard"] = uca;
            return(View());
        }
Example #3
0
        //
        // GET: /User/

        public ActionResult Index()
        {
            user_table user = (user_table)Session["user"];

            if (user == null)
            {
                Response.Redirect("/user/login");
            }

            ucard uca = db.ucard.SingleOrDefault <ucard>(uc => uc.uid == user.id);

            if (uca == null)
            {
                uca     = new ucard();
                uca.uid = user.id;
                db.ucard.AddObject(uca);
                db.SaveChanges();
            }
            ViewData["ucard"] = uca;
            return(View());
        }