Beispiel #1
0
 public ActionResult AddProduct()
 {
     User user = (User)Session["User"];
     ShopManager shopMgr = new ShopManager(user);
     List<Category> cates = shopMgr.GetCategories();
     cates = (from c in cates where c.ParentID == 0 && c.Enabled==true select c).ToList<Category>();
     ViewData["cate"] = cates;
     return View();
 }
Beispiel #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            User user = null;
            if (filterContext.HttpContext.Session["User"] == null)
            {
                user = (User)filterContext.HttpContext.Session["User"];
            }

            ShopManager shopMgr = new ShopManager(user);
            filterContext.HttpContext.Session["category"] = shopMgr.GetCategories();
        }
Beispiel #3
0
        public JsonResult Categories()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage() { Status = "ok" };
            User user = (User)Session["User"];
            ShopManager shopMgr = new ShopManager(user);
            string pid = Request["parentId"];
            int parentId = 0;

            int.TryParse(pid, out parentId);

            List<Category> cates = shopMgr.GetCategories();

            cates = (from c in cates where c.ParentID == parentId select c).ToList<Category>();

            res.Data=cates;

            return res;
        }
Beispiel #4
0
        public ActionResult EditProduct(int id)
        {
            User user = (User)Session["User"];
            ShopManager shopMgr = new ShopManager(user);
            List<Category> cates = shopMgr.GetCategories();
            List<Category> ccates = null;
            Product product = shopMgr.GetProduct(id);
            List<Image> images = shopMgr.GetProductImages(id);
            Category category = (from c in cates where c.ID == product.CategoryID select c).FirstOrDefault<Category>();

            int pcid = 0;
            if (category.ParentID > 0)
            {
                pcid = (int)category.ParentID;
                ccates = (from c in cates where c.ParentID == category.ParentID select c).ToList<Category>();
            }

            cates = (from c in cates where c.ParentID == 0 select c).ToList<Category>();
            ViewData["cate"] = cates;
            ViewData["ccate"] = ccates;
            ViewData["images"] = images;
            ViewBag.pcid = pcid;
            return View(product);
        }