Beispiel #1
0
        public ActionResult AddGoods()
        {
            ShopManager shopManager = new ShopManager();

            if (Session["UserID"] != null)
            {
                int userid = int.Parse(Session["UserID"].ToString());
                var s      = shopManager.GetShop(userid);
                //判断当前用户有没有开设店铺
                if (s != null)
                {
                    //获取当前用户店铺ID
                    Session["ShopID"] = s.ShopID;

                    //获取分类的id和对应的分类名
                    PurchaSalerEntities db = new PurchaSalerEntities();
                    ViewBag.categoryid = new SelectList(db.Categories, "CategoryID", "CategoryName");

                    return(View("AddGoods"));//转到发布商品视图
                }
                else
                {
                    return(RedirectToAction("AddShop", "Shop"));//转到添加商铺视图
                }
            }
            else
            {
                return(Content("<script>alert('请先登录!');window.location.href = document.referrer;</script>"));
            }
        }
Beispiel #2
0
        public ActionResult ShopCart(int UserID)
        {
            //var shopCart = shopCartManager.GetShopCarts(UserID);
            PurchaSalerEntities db = new PurchaSalerEntities();
            var cart = from a in db.ShopCarts
                       where a.UserID == UserID
                       join b in db.Goods on a.GoodID equals b.GoodID
                       select new View_ShopCart
            {
                GoodID    = a.GoodID,
                UserID    = a.UserID,
                GoodPhoto = b.GoodPhoto,
                GoodTitle = b.GoodTitle,
                Price     = a.Price,
                Amount    = a.Amount,
                Total     = a.Total
            };

            return(View(cart));
        }