Example #1
0
        public ActionResult Edit(int id = 0)
        {
            List <SelectListItem> parents = new List <SelectListItem>();

            foreach (var parent in CategoryDALC.GetAll().Select(row => new { row.Id, row.Path }))
            {
                parents.Add(new SelectListItem
                {
                    Text  = parent.Path,
                    Value = parent.Id.ToString()
                });
            }
            CategoryViewModel model = new CategoryViewModel();

            if (id == 0)
            {
                model.ParentCategories = parents;
                return(View(model));
            }
            else
            {
                model = MapToCategoryViewModel(CategoryDALC.GetById(id));
                model.ParentCategories = parents;
                return(View(model));
            }
        }
Example #2
0
        public ActionResult Index()
        {
            var model = CategoryDALC.GetAll().Select(category => MapToCategoryViewModel(category)).ToList();

            return(View(model));
        }
Example #3
0
        public ActionResult CategoriesList()
        {
            var model = CategoryDALC.GetAll().Select(category => MapToCategoryViewModel(category)).ToList();

            return(PartialView("_CategoriesList", model));
        }