Пример #1
0
        public void Delete(int CartID)
        {
            var cart = db.Cart.Where(o => o.CartID == CartID).FirstOrDefault();

            db.Cart.Remove(cart);
            db.SaveChanges();
        }
        public void DirectBuy(int GoodsID, DateTime dateTime, int ID, int Num)
        {
            var Goods = db.Goods.Where(o => o.GoodsID == GoodsID).FirstOrDefault();

            Goods.Amount = Goods.Amount - Num;
            db.SaveChanges();
            var orders = db.Orders.Where(o => o.UserID == ID);

            foreach (var i in orders)
            {
                var t = i.OrderTime;
                if (t == dateTime)
                {
                    //var OrderID = i.OrderID;
                    var order   = db.Orders.Where(u => u.OrderTime == dateTime).FirstOrDefault();
                    var orderid = order.OrderID;
                    //var o = new OrderDetails()
                    //{
                    //    GoodsID = GoodsID,
                    //    Count = Num,
                    //    UserID = ID,
                    //    OrderID = orderid
                    //};


                    //db.OrderDetails.Add(o);

                    db.SaveChanges();
                }
            }
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "AddressID,Address1,UserID")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Address.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "Password", address.UserID);
            return(View(address));
        }
        public ActionResult Create([Bind(Include = "OrderID,OrderTime,TotalAmount,UserID,UserName,Tel,Address")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(orders);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "Password", orders.UserID);
            return(View(orders));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "ComReplyID,UserID,GoodsCommentID,RepContent,RepTime")] ComReply comReply)
        {
            if (ModelState.IsValid)
            {
                db.ComReply.Add(comReply);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GoodsCommentID = new SelectList(db.GoodsComment, "GoodsCommentID", "ComContent", comReply.GoodsCommentID);
            ViewBag.UserID         = new SelectList(db.Users, "UserID", "Password", comReply.UserID);
            return(View(comReply));
        }
        public ActionResult Create([Bind(Include = "GoodsCommentID,ComContent,ComImage,Video,ImageOrNot,VideoOrNot,UserID,GoodsID,ComTime,ThumbNum")] GoodsComment goodsComment)
        {
            if (ModelState.IsValid)
            {
                db.GoodsComment.Add(goodsComment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GoodsID = new SelectList(db.Goods, "GoodsID", "Name", goodsComment.GoodsID);
            ViewBag.UserID  = new SelectList(db.Users, "UserID", "Password", goodsComment.UserID);
            return(View(goodsComment));
        }
Пример #7
0
        public void Order(DateTime datetime, int totalamount, int userid, string uname, string tel, string address)
        {
            var order = new Orders()
            {
                OrderTime   = datetime,
                TotalAmount = totalamount,
                UserID      = userid,
                UserName    = uname,
                Tel         = tel,
                Address     = address
            };

            db.Orders.Add(order);
            db.SaveChanges();
        }
Пример #8
0
        public ActionResult RecomGoods()
        {
            //int userid =6;
            int userid       = Convert.ToInt32(Session["User_id"]);
            var cart         = db.Cart.Where(u => u.UserID == userid).FirstOrDefault();
            var orderdetails = db.OrderDetails.Where(u => u.UserID == userid).FirstOrDefault();

            if (cart != null)
            {
                SqlParameter        id     = new SqlParameter("@userid", userid);
                IEnumerable <Goods> goods1 = db.Database.SqlQuery <Goods>("exec [Cart_Goods] @userid", id).Cast <Goods>().ToList();
                db.SaveChanges();
                return(View(goods1));
            }

            else if (orderdetails != null)
            {
                SqlParameter        id     = new SqlParameter("@userid", userid);
                IEnumerable <Goods> goods1 = db.Database.SqlQuery <Goods>("exec [OrderDetails_Goods] @userid", id).Cast <Goods>().ToList();
                db.SaveChanges();
                return(View(goods1));
            }
            else
            {
                var s1 = from c in db.Cart


                         select c;
                var s2 = from o in db.OrderDetails
                         select o;


                foreach (var i in s2)
                {
                    var goods = goodsmanager.GetNewGoods(20);
                    if (userid != i.UserID)
                    {
                        return(View(goods));
                    }
                }
                var goods2 = goodsmanager.GetNewGoods(20);
                return(View(goods2));
            }
        }
Пример #9
0
        public void Notelikeclick(int userid, int noteid)
        {
            NoteLike like = db.NoteLike.Where(b => b.UserID == userid && b.NoteID == noteid).FirstOrDefault();

            if (like != null)
            {
                db.NoteLike.Remove(like);
                db.SaveChanges();
            }
            else
            {
                NoteLike like1 = new NoteLike();
                like1.NoteID = noteid;
                like1.UserID = userid;
                like1.Time   = DateTime.Now;
                db.NoteLike.Add(like1);
                db.SaveChanges();
            }
        }
Пример #10
0
        public void GoodsLikeClick(int userid, int goodsid)
        {
            GoodsLike like = db.GoodsLike.Where(u => u.UserID == userid && u.GoodsID == goodsid).FirstOrDefault();

            if (like != null)
            {
                db.GoodsLike.Remove(like);
                db.SaveChanges();
            }
            else
            {
                GoodsLike like1 = new GoodsLike();
                like1.GoodsID   = goodsid;
                like1.UserID    = userid;
                like1.ThumbTime = DateTime.Now;
                db.GoodsLike.Add(like1);
                db.SaveChanges();
            }
        }
Пример #11
0
        public void Videolikeclick(int userid, int videoid)
        {
            VideoLike like = db.VideoLike.Where(b => b.UserID == userid && b.VideoID == videoid).FirstOrDefault();

            if (like != null)
            {
                db.VideoLike.Remove(like);
                db.SaveChanges();
            }
            else
            {
                VideoLike like1 = new VideoLike();
                like1.VideoID = videoid;
                like1.UserID  = userid;
                like1.Time    = DateTime.Now;
                db.VideoLike.Add(like1);
                db.SaveChanges();
            }
        }
Пример #12
0
        public void VideoSelect(int userid, int videoid)
        {
            VideoSelect select = db.VideoSelect.Where(b => b.UserID == userid && b.VideoID == videoid).FirstOrDefault();

            if (select != null)
            {
                db.VideoSelect.Remove(select);
                db.SaveChanges();
            }
            else
            {
                VideoSelect select1 = new VideoSelect();
                select1.VideoID = videoid;
                select1.UserID  = userid;
                select1.Time    = DateTime.Now;
                db.VideoSelect.Add(select1);
                db.SaveChanges();
            }
        }
Пример #13
0
        public void NoteSelect(int userid, int noteid)
        {
            NoteSelect select = db.NoteSelect.Where(b => b.UserID == userid && b.NoteID == noteid).FirstOrDefault();

            if (select != null)
            {
                db.NoteSelect.Remove(select);
                db.SaveChanges();
            }
            else
            {
                NoteSelect select1 = new NoteSelect();
                select1.NoteID = noteid;
                select1.UserID = userid;
                select1.Time   = DateTime.Now;
                db.NoteSelect.Add(select1);
                db.SaveChanges();
            }
        }
Пример #14
0
        public void AddComReply(int userid, int goodscommentid, string replycontent, DateTime replytime)
        {
            var comreply = new ComReply()
            {
                UserID         = userid,
                GoodsCommentID = goodscommentid,
                RepContent     = replycontent,
                RepTime        = replytime
            };

            db.ComReply.Add(comreply);
            db.SaveChanges();
        }
Пример #15
0
        //[Bind(Include = "GoodsID,Name,Sex,Season,Material,Style,GoodsImage,Amount,Unitprice,Type,SizeImage,ShangjiaTime,Pageview,TotalStorageAmount,ThumbNum")]
        public ActionResult Create(Goods goods)
        {
            var goodsimage = Request.Files["imgfile"];
            var name       = Request["name"].ToString();
            var sex        = Request["sex"].ToString();
            var season     = Request["season"].ToString();
            var material   = Request["material"].ToString();
            var type       = Request["type"].ToString();
            //var sex = Request["sex"].ToString();
            var time = System.DateTime.Now;

            if (ModelState.IsValid)
            {
                if (goodsimage != null)
                {
                    goods.Name         = name;
                    goods.Sex          = sex;
                    goods.Season       = season;
                    goods.Material     = material;
                    goods.Type         = type;
                    goods.ShangjiaTime = time;
                    string filePath = Guid.NewGuid().ToString() + goodsimage.FileName;



                    goodsimage.SaveAs(Request.MapPath("/Images/GoodsImages/" + filePath));
                    goods.GoodsImage = "../GoodsImages/" + filePath;
                }
                db.Goods.Add(goods);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(goods));
        }
Пример #16
0
        public void Add(int userid, string address)
        {
            var p = db.Address.Where(u => u.Address1 == address).FirstOrDefault();

            if (p == null)
            {
                var add = new Address()
                {
                    UserID   = userid,
                    Address1 = address,
                };
                db.Address.Add(add);
                db.SaveChanges();
            }
        }
Пример #17
0
        public void AddGoodsComment(string com, int userid, int goodsid, DateTime datetime, int num)
        {
            //db.GoodsComment.Add(goodscomment);
            //db.SaveChanges();
            var Comment = new GoodsComment()
            {
                ComContent = com,
                UserID     = userid,
                GoodsID    = goodsid,
                ComTime    = datetime,
                ThumbNum   = num
            };

            db.GoodsComment.Add(Comment);
            db.SaveChanges();
        }
Пример #18
0
        public bool Register(string TrueName, string PasswordR, string Tel)
        {
            if (db.Users.Any(x => x.Tel == Tel))
            {
                return(false);
            }
            else
            {
                var users = new Users()
                {
                    UserName = TrueName,

                    Password = PasswordR,
                    Tel      = Tel
                };
                db.Users.Add(users);
                db.SaveChanges();
                return(true);
            }
        }
 public void AddNoteCommentReply(U_Reply_NoteComment notecommentreply)
 {
     db.U_Reply_NoteComment.Add(notecommentreply);
     db.SaveChanges();
 }
Пример #20
0
 public void addattention(U_Attention_U attention)
 {
     db.U_Attention_U.Add(attention);
     db.SaveChanges();
 }
Пример #21
0
 public void AddVideoCommentReply(U_Reply_VideoComment videocommentreply)
 {
     db.U_Reply_VideoComment.Add(videocommentreply);
     db.SaveChanges();
 }
Пример #22
0
 public void AddShirt(Shirt shirt)
 {
     db.Shirt.Add(shirt);
     db.SaveChanges();
 }
Пример #23
0
 public void AddGoods(Goods goods)
 {
     db.Goods.Add(goods);
     db.SaveChanges();
 }
 public void AddNether(NetherGarment nether)
 {
     db.NetherGarment.Add(nether);
     db.SaveChanges();
 }
Пример #25
0
 public void AddNoteComment(NoteComment notecomment)
 {
     db.NoteComment.Add(notecomment);
     db.SaveChanges();
 }
Пример #26
0
 public void AddVideoComment(VideoComment videocomment)
 {
     db.VideoComment.Add(videocomment);
     db.SaveChanges();
 }
Пример #27
0
 public void AddVideo(Video video)
 {
     db.Video.Add(video);
     db.SaveChanges();
 }
Пример #28
0
 public void AddNote(Note note)
 {
     db.Note.Add(note);
     db.SaveChanges();
 }
Пример #29
0
 public void AddCoat(Coat coat)
 {
     db.Coat.Add(coat);
     db.SaveChanges();
 }
Пример #30
0
 public void AddSuit(Suit suit)
 {
     db.Suit.Add(suit);
     db.SaveChanges();
 }