Пример #1
0
        public ActionResult CategoryItems(int catID = 0, string unknown = "")
        {
            List<ConvertedPart> parts = new List<ConvertedPart>();
            if (catID != 0) {
                // Get the category
                DetailedCategories cat = new DetailedCategories();
                cat = ProductCat.GetCategory(catID);
                ViewBag.cat = cat;

                // Get the category items
                parts = ProductCat.GetCategoryItems(catID);

            } else if (catID == 0 && unknown == "unknown") {
                DetailedCategories cat = new DetailedCategories();
                cat.catTitle = "Uncategorized Parts";
                ViewBag.cat = cat;

                // Get the uncategorized parts
                parts = ProductCat.GetUncategorizedParts();

            }
            ViewBag.parts = parts;
            ViewBag.partCount = parts.Count();

            return View();
        }
Пример #2
0
        /// <summary>
        /// Get a given category's information
        /// </summary>
        /// <param name="catID">ID of the category</param>
        /// <returns>DetailedCategories object</returns>
        public static DetailedCategories GetCategory(int catID = 0)
        {
            DetailedCategories cat = new DetailedCategories();
            CurtDevDataContext db = new CurtDevDataContext();

            cat = (from c in db.Categories
                   join cp in db.CatParts on c.catID equals cp.catID into CParts from cp in CParts.DefaultIfEmpty()
                   where c.catID.Equals(catID)
                   select new DetailedCategories {
                       catID = c.catID,
                       dateAdded = c.dateAdded,
                       parentID = c.parentID,
                       parentCat = (from c2 in db.Categories where c2.catID.Equals(c.parentID) select c2.catTitle).FirstOrDefault<string>(),
                       catTitle = c.catTitle,
                       shortDesc = c.shortDesc,
                       longDesc = c.longDesc,
                       image = c.image,
                       isLifestyle = c.isLifestyle,
                       vehicleSpecific = c.vehicleSpecific,
                       partCount = (from p in db.Parts where p.partID.Equals(cp.partID) select p).Count(),
                       content = (from cb in db.ContentBridges
                                  join co in db.Contents on cb.contentID equals co.contentID
                                  join ct in db.ContentTypes on co.cTypeID equals ct.cTypeID
                                  where cb.catID.Equals(c.catID)
                                  orderby co.cTypeID
                                  select new FullContent {
                                      content_type_id = co.cTypeID,
                                      content_type = ct.type,
                                      contentID = co.contentID,
                                      content = co.text
                                  }).ToList<FullContent>()

                   }).FirstOrDefault<DetailedCategories>();
            return cat;
        }
Пример #3
0
        public ActionResult Edit(int catID, string catTitle = "", int parentID = 0, string image = "", int isLifestyle = 0, string shortDesc = "", string longDesc = "", bool vehicleSpecific = false)
        {
            List<string> error_messages = new List<string>();
            DetailedCategories cat = new DetailedCategories();
            try {
                Categories category = ProductCat.SaveCategory(catID, catTitle, parentID, image, isLifestyle, shortDesc, longDesc, vehicleSpecific);
            } catch (Exception e) {
                error_messages.Add(e.Message);
            }

            if (error_messages.Count == 0) {
                return RedirectToAction("Index");
            }
            ViewBag.error_messages = error_messages;
            // Get this category
            cat = ProductCat.GetCategory(catID);
            ViewBag.cat = cat;

            // Get the categories so the use can make the new one a subcategory if they choose
            List<DetailedCategories> cats = ProductCat.GetCategories();
            ViewBag.cats = cats;

            return View();
        }