示例#1
0
        //提交订单去结账
        public JsonResult endAll()
        {
            var c_user = HttpContext.Cache["c_User"] as T_user;
            var uid    = c_user.userId;

            GoShoesDBEntities db = new GoShoesDBEntities();

            var ss = db.T_buyCar.Where(c => c.userId == uid).ToList();

            foreach (var item in ss)
            {
                db.T_buyCar.Remove(item);
            }

            int rs  = db.SaveChanges();
            var obj = new {
                msg  = "提交失败",
                code = 201
            };

            if (rs > 0)
            {
                obj = new {
                    msg  = "提交成功",
                    code = 201
                };
            }

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public JsonResult Ban(int uid)
        {
            GoShoesDBEntities db = new GoShoesDBEntities();

            var s = db.T_user.Where(c => c.userId == uid).FirstOrDefault();

            if (s.userClose == 1)
            {
                s.userClose = 0;
                var obj2 = new { msg = "解封失败", code = 203 };

                int rs2 = db.SaveChanges();



                if (rs2 > 0)
                {
                    obj2 = new { msg = "解封成功", code = 204 };
                }

                return(Json(obj2));
            }


            s.userClose = 1;


            int rs = db.SaveChanges();

            var obj = new { msg = "封禁失败", code = 201 };

            if (rs > 0)
            {
                obj = new { msg = "封禁成功", code = 200 };
            }

            return(Json(obj));
        }
示例#3
0
        public JsonResult userRegister(string name, string pwd, string rePwd)
        {
            //var s = new
            //{
            //    userName = name,
            //    userPassword = pwd,
            //    userPowerId = 2,
            //    userClose = 0
            //};

            var obj = new
            {
                msg  = "注册失败",
                code = 201
            };

            if (string.IsNullOrEmpty(name))
            {
                obj = new
                {
                    msg  = "用户名不能为空",
                    code = 203
                };
                return(Json(obj));
            }
            if (string.IsNullOrEmpty(pwd))
            {
                obj = new
                {
                    msg  = "密码不能为空",
                    code = 204
                };
                return(Json(obj));
            }


            if (string.IsNullOrEmpty(rePwd))
            {
                obj = new
                {
                    msg  = "再次输入密码不能为空",
                    code = 205
                };
                return(Json(obj));
            }
            if (pwd != rePwd)
            {
                obj = new
                {
                    msg  = "两次输入密码不一样",
                    code = 206
                };
                return(Json(obj));
            }
            GoShoesDBEntities db = new GoShoesDBEntities();
            var abc = db.T_user.Where(c => c.userName == name).FirstOrDefault();

            if (abc != null)
            {
                obj = new
                {
                    msg  = "注册失败,用户存在",
                    code = 202
                };
                return(Json(obj));
            }
            T_user s = new T_user();

            s.userName     = name;
            s.userPassword = pwd;
            s.userPowerId  = 2;
            s.userClose    = 0;
            db.T_user.Add(s);
            int rs = db.SaveChanges();

            if (rs > 0)
            {
                obj = new { msg = "注册成功", code = 200 }
            }
            ;

            var ss = db.T_user.Where(c => c.userName == s.userName).FirstOrDefault();

            HttpContext.Cache["c_User"] = s;

            return(Json(obj));
        }
    }
示例#4
0
        public JsonResult CreateCar(string shoesName, int shoesPrice, string shoesImg, int shoesNum)
        {
            var obj = new
            {
                msg  = "添加购物车失败",
                code = 201
            };
            var user = HttpContext.Cache["c_User"] as T_user;
            var uid  = user.userId;

            GoShoesDBEntities db = new GoShoesDBEntities();
            //用鞋名  查出鞋id
            var shoesId = db.T_shoes.Where(c => c.shoesName == shoesName).FirstOrDefault().shoesId;

            //看看购物车是否存在这鞋子
            var s = db.T_buyCar.Where(c => c.shoesId == shoesId).FirstOrDefault();

            if (s != null)
            {
                //如果有这个鞋子 那么久是加鞋数量
                s.carNum      += shoesNum;
                s.shoesPrices += shoesPrice;
                int rs = db.SaveChanges();

                if (rs > 0)
                {
                    obj = new
                    {
                        msg  = "添加购物成功",
                        code = 201
                    };
                }//rs
                return(Json(obj));
            }



            //如果没有这个鞋子
            T_buyCar car = new T_buyCar();

            car.carNum      = shoesNum;
            car.shoesImg    = shoesImg;
            car.shoesId     = shoesId;
            car.shoesPrices = shoesPrice;
            car.userId      = uid;

            db.T_buyCar.Add(car);

            int rs1 = db.SaveChanges();

            if (rs1 > 0)
            {
                obj = new
                {
                    msg  = "添加购物车成功",
                    code = 200
                };
            }//rs

            return(Json(obj));
        }