Esempio n. 1
0
        public override bool TakeAction()
        {
            HXSCEntities hxsc = new HXSCEntities();

            if (hxsc.UserInfo.FirstOrDefault(u => u.Userid == Userid) == null)
            {
                return(SetError("用户不存在!"));
            }
            if (hxsc.Item.FirstOrDefault(u => u.Itemid == Itemid) == null)
            {
                return(SetError("图书不存在!"));
            }
            Shoppingbasket shopingbasket = new Shoppingbasket()
            {
                Createtime = DateTime.Now,
                Itemid     = Itemid,
                Source     = key,
                State      = 0,
                Userid     = Userid
            };

            hxsc.Shoppingbasket.AddObject(shopingbasket);
            hxsc.SaveChanges();
            return(true);
        }
Esempio n. 2
0
        public override bool TakeAction()
        {
            HXSCEntities   hxsc           = new HXSCEntities();
            Shoppingbasket Shoppingbasket = hxsc.Shoppingbasket.FirstOrDefault(u => u.Shoppingbasketid == shoppingbasketid);

            if (Shoppingbasket == null)
            {
                return(SetError("购物车中商品不存在!"));
            }
            Shoppingbasket.State = 1;
            hxsc.SaveChanges();
            return(true);
        }