Ejemplo n.º 1
0
        public JsonResult AddToOrder(int pro_id, int type_id, int num, string address, string marks, string name, string tele)
        {
            tip t        = null;
            var datetime = System.DateTime.Now;

            Order_Detail b = new Order_Detail()
            {
                User_ID       = (int)Session["userid"],
                Product_ID    = pro_id,
                Pay_Time      = datetime,
                Pro_Norm_ID   = type_id,
                Pro_Num       = num,
                Users_Remarks = marks,
                Adress        = address.Trim(),
            };

            db.Order_Detail.Add(b);
            db.SaveChanges();
            try
            {
                t = new tip
                {
                    message = "下单成功"
                };
            }
            catch (Exception d)
            {
                throw d;
            }
            return(base.Json(t));
        }
Ejemplo n.º 2
0
        public JsonResult Guanzhu(int UserB)
        {
            //Guanzhu gz = new Guanzhu();
            //gz.UserA = (int)Session["userid"];
            //gz.UserB = UserB;
            //userManager.Guanzhu(gz);
            //int a = userManager.CountGuanzhu1(UserB).Count();
            //return a;
            tip     t      = null;
            int     userid = (int)Session["userid"];
            Guanzhu gz     = new Guanzhu();
            Guanzhu g      = new Guanzhu()
            {
                UserA = userid,
                UserB = UserB
            };

            dbContext.Guanzhu.Add(g);
            try
            {
                dbContext.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
            t = new tip()
            {
                message = "关注成功",
                code    = 5
            };
            return(base.Json(t));
        }
Ejemplo n.º 3
0
        public JsonResult Comment(string comment, int pro_id)
        {
            tip t        = null;
            var datetime = System.DateTime.Now;

            Comment_Product z = new Comment_Product()
            {
                UserID      = (int)Session["userid"],
                Com_Content = comment,
                Com_Data    = datetime,
                Product_ID  = pro_id
            };

            db.Comment_Product.Add(z);
            try
            {
                db.SaveChanges();
                t = new tip
                {
                    message = "评论成功"
                };
            }
            catch (Exception d)
            {
                throw d;
            }
            return(base.Json(t));
        }
Ejemplo n.º 4
0
        public JsonResult Attention(int Followed_Userid, int tag)
        {
            tip t       = null;
            int fans_id = (int)Session["userid"];

            if (tag == 1)
            {
                //关注
                follow_repository.AddAttention(Followed_Userid, fans_id);
                t = new tip()
                {
                    message = "关注成功",
                    code    = 200
                };
            }
            else
            {
                Follow f = lpe.Follow.Where(e => (e.Followed_Person == Followed_Userid && e.Fans == fans_id)).FirstOrDefault();
                lpe.Follow.Remove(f);
                lpe.SaveChanges();
                t = new tip()
                {
                    message = "取消关注成功",
                    code    = 200
                };
            }
            return(base.Json(t));
        }
Ejemplo n.º 5
0
        public JsonResult AddToCart(int pro_id, int type_id, int num)
        {
            tip  t        = null;
            var  datetime = System.DateTime.Now;
            Cart c        = new Cart()
            {
                Product_ID  = pro_id,
                Pro_Num     = num,
                Pro_Norm_id = type_id,
                UserID      = (int)Session["userid"],
                Time        = datetime,
                Flag        = 0
            };

            db.Cart.Add(c);
            try
            {
                db.SaveChanges();
                t = new tip
                {
                    message = "添加成功"
                };
            }
            catch (Exception e)
            {
                throw e;
            }
            return(base.Json(t));
        }
Ejemplo n.º 6
0
        public JsonResult UploadHeaderPic(HttpPostedFileBase file = null)
        {
            int  userid = (int)Session["userid"];
            User u      = lpe.User.Find(userid);
            tip  t      = null;

            if (file != null && u != null)
            {
                u.ImageData     = new byte[file.ContentLength];
                u.ImageMineType = file.ContentType;
                file.InputStream.Read(u.ImageData, 0, file.ContentLength);
                try
                {
                    lpe.SaveChanges();
                    t = new tip()
                    {
                        message = "上传成功",
                        code    = 200
                    };
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                t = new tip()
                {
                    message = "上传失败",
                    code    = 200
                };
            }
            return(base.Json(t));
        }
Ejemplo n.º 7
0
        public JsonResult Login(string account, string password)
        {
            tip t = null;
            AdminLoginStatus als = admin_repository.LoginIn(account, password);

            if (als.status)
            {
                t = new tip()
                {
                    message = "登陆成功",
                    code    = 200
                };
                //将管理员加入当前会话
                Session["admin"] = als.admin;
            }
            else
            {
                t = new tip()
                {
                    message = "登陆失败",
                    code    = 500
                };
            }
            return(base.Json(t));
        }
Ejemplo n.º 8
0
        public JsonResult ModifyAccess(int accessibility, int postid, int userid)
        {
            tip t = new tip()
            {
                message = "帖子权限已被修改",
                code    = 200
            };
            Post p = lpe.Post.Where(e => e.PostID == postid).FirstOrDefault();

            if (p != null)
            {
                p.Accessibility = accessibility;
                lpe.SaveChanges();
            }
            return(base.Json(t));
        }
Ejemplo n.º 9
0
        public JsonResult AddToOrder(string address, string marks)
        {
            tip t        = null;
            var userid   = (int)Session["userid"];
            var carts    = lpe.Cart.Where(e => e.UserID == userid);
            var datetime = System.DateTime.Now;

            foreach (var i in carts)
            {
                i.Flag = 1;
                var product_id = i.Product_ID;

                var orderdetails = new Order_Detail()
                {
                    Product_ID    = product_id,
                    Pro_Num       = i.Pro_Num,
                    Pay_Time      = datetime,
                    User_ID       = i.UserID,
                    Users_Remarks = marks,
                    Adress        = address,
                    Pro_Norm_ID   = i.Pro_Norm_id
                };
                lpe.Order_Detail.Add(orderdetails);
            }
            try
            {
                lpe.SaveChanges();
                t = new tip
                {
                    message = "下单成功"
                };
            }
            catch (Exception d)
            {
                throw d;
            }
            //删除购物车中的订单
            var cart = lpe.Cart.Where(e => e.Flag == 1);

            foreach (var i in cart)
            {
                lpe.Cart.Remove(i);
            }
            lpe.SaveChanges();
            return(base.Json(t));
        }
Ejemplo n.º 10
0
        public JsonResult Index(string UserName, string Phone, string Email, string Password)
        {
            User u = new User()
            {
                UserName = UserName,
                Email    = Email,
                Phone    = Phone,
                Password = Password
            };

            //调用注册方法
            UIRepository.AddUser(u);
            tip t = new tip
            {
                message = "注册成功",
                code    = 200
            };

            return(base.Json(t));
        }
Ejemplo n.º 11
0
        public JsonResult UserSetting(string username = null, string phone = null, string signature = null, string birthday = null, string sex = null)
        {
            int userid = (int)Session["userid"];
            tip t      = null;

            try
            {
                user_repository.SaveEditor(userid, username, phone, signature, birthday, sex);
                t = new tip()
                {
                    message = "编辑成功",
                    code    = 200
                };
            }
            catch (Exception e)
            {
                throw e;
            }
            return(base.Json(t));
        }
Ejemplo n.º 12
0
        public JsonResult CollectPost(int postid, int tag)
        {
            int     userid = (int)Session["userid"];
            tip     t      = null;
            Collect co     = lpe.Collect.Where(e => (e.Post_Id == postid && e.User_Id == userid)).FirstOrDefault();

            if (tag == 1)
            {
                Collect c = new Collect()
                {
                    Collect_Type = "论坛帖子",
                    User_Id      = userid,
                    Post_Id      = postid
                };
                lpe.Collect.Add(c);
                t = new tip()
                {
                    message = "收藏成功",
                    code    = 200
                };
            }
            else if (co != null)
            {
                lpe.Collect.Remove(co);
                t = new tip()
                {
                    message = "取消收藏成功",
                    code    = 200
                };
            }

            try
            {
                lpe.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
            return(base.Json(t));
        }
Ejemplo n.º 13
0
        public JsonResult dop(int creNum, int?Comid, int?Repid)
        {
            tip t;
            int userid = (int)Session["userid"];

            //对评论的点赞
            if (Comid != null)
            {
                praised_repository.ForCom(creNum, (int)Comid, userid);
            }
            else
            {
                praised_repository.ForRep(creNum, (int)Repid, userid);
            }
            t = new tip()
            {
                message = "操作成功",
                code    = 200
            };
            return(base.Json(t));
        }
Ejemplo n.º 14
0
        public JsonResult CollectCourse(int?id, int tag)
        {
            int     userid = (int)Session["userid"];
            tip     t      = null;
            Collect co     = dbContext.Collect.Where(b => (b.Course_Id == id && b.User_Id == userid)).FirstOrDefault();

            if (tag == 1)
            {
                Collect c = new Collect()
                {
                    Collect_Type = "课程",
                    User_Id      = userid,
                    Course_Id    = id
                };
                dbContext.Collect.Add(c);
                t = new tip()
                {
                    message = "收藏成功",
                    code    = 200
                };
            }
            else if (co != null)
            {
                dbContext.Collect.Remove(co);
                t = new tip()
                {
                    message = "取消收藏成功",
                    code    = 200
                };
            }
            try
            {
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(base.Json(t));
        }
Ejemplo n.º 15
0
        public JsonResult Index(string key, string password)
        {
            tip         t  = null;
            LoginStatus ls = UIRepository.LoginIn(key, password);

            if (ls.status)
            {
                t = new tip
                {
                    message = "登陆成功",
                    code    = 200
                };
                Session["user"]   = ls.user;
                Session["userid"] = ls.user.UserID;
            }
            else
            {
                Teacher l = lpe.Teacher.Where(e => e.Password == password && e.Phone == key).FirstOrDefault();
                if (l != null)
                {
                    t = new tip
                    {
                        message = "登陆成功",
                        code    = 200
                    };
                    Session["teacher"]   = l;
                    Session["teacherid"] = l.TeacherID;
                }
                else
                {
                    t = new tip
                    {
                        message = "密码错误",
                        code    = 500
                    };
                }
            }
            return(base.Json(t));
        }