示例#1
0
        // GET: /Admin/CMS_Category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var category = _cmsCategoryService.GetCategoryById(id);

            if (category == null)
            {
                return(HttpNotFound());
            }

            ViewBag.AvailableCategories = PrepareAllCategoriesModel(id.Value);
            PopulateStatusDropDownList((Portal.Infractructure.Utility.Define.Status)category.Status);
            return(View(category));
        }
示例#2
0
        // GET: /News/
        public ActionResult Index(int?id, int page = 1)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            PopulateCMSChildCategoriesByParentId(id.Value);
            PopulateRecentNews();

            var category = _cmsCategoryService.GetCategoryById(id.Value);

            ViewBag.CategoryTitle = category.Title;

            int totalItems = 0;
            var news       = _cmsNewsService.GetCMSNewsByCategoryId(id.Value, page, OnlineStore.Infractructure.Utility.Define.PAGE_SIZE, out totalItems);
            IPagedList <CMSNewsView> pageNews = new StaticPagedList <CMSNewsView>(news, page, OnlineStore.Infractructure.Utility.Define.PAGE_SIZE, totalItems);

            return(View(pageNews));
        }
        public static IList <CMSCategoryView> GetCategoryBreadCrumb(CMSCategoryView category, ICMSCategoryService categoryService)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }

            var result = new List <CMSCategoryView>();

            //used to prevent circular references
            var alreadyProcessedCategoryIds = new List <int>();

            while (category != null &&                                 //not null
                   !alreadyProcessedCategoryIds.Contains(category.Id)) //prevent circular references
            {
                result.Add(category);

                alreadyProcessedCategoryIds.Add(category.Id);

                category = categoryService.GetCategoryById(category.ParentId);
            }
            result.Reverse();
            return(result);
        }