public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var category = _cmsCategoryService.GetCMSCategoryById(id);

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

            ViewBag.AvailableCategories = PrepareAllCategoriesModel(id.Value);
            PopulateStatusDropDownList((Define.Status)category.Status);
            return(View(category));
        }
        public static IList <CMSCategoryViewModel> GetCategoryBreadCrumb(CMSCategoryViewModel category, ICMSCategoryService categoryService)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }

            var result = new List <CMSCategoryViewModel>();

            //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.GetCMSCategoryById(category.ParentId);
            }
            result.Reverse();
            return(result);
        }