Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public IActionResult PanelEditCategory(string param)
        {
            if (string.IsNullOrWhiteSpace(param))
                return PanelListCategories();

            Guid guid = Guid.Parse(param);
            Category cat = _ctx.Categories.GetCategory(guid);

            CreateEditCategoryViewModel cecvm = new CreateEditCategoryViewModel();
            cecvm.Category = cat;
            cecvm.CanDelete = cat.CategoryID != Guid.Empty;

            if (guid == Guid.Empty)
                cecvm.IsDefault = true;

            cecvm.Categories = _ctx.Categories.GetCategories();

            return PartialView("Admin/Categories/_categoryCreateEdit", cecvm);
        }
Esempio n. 2
0
        public IActionResult SaveCategory(CreateEditCategoryViewModel cecvm)
        {
            if (cecvm.IsToDelete)
                return DeleteCategory(cecvm.Category.CategoryID.ToString());

            Category cat = cecvm.Category;

            if (cat.CategoryID == Guid.Empty && !cecvm.IsDefault)
                cat.CategoryID = Guid.NewGuid();

            _ctx.Categories.SaveCategory(cat);

            return RedirectToAction("categories");
        }
Esempio n. 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IActionResult PanelCreateCategory()
        {
            CreateEditCategoryViewModel cecvm = new CreateEditCategoryViewModel();
            cecvm.Categories = _ctx.Categories.GetCategories();

            return PartialView("Admin/Categories/_categoryCreateEdit", cecvm);
        }