Пример #1
0
        public async Task <IActionResult> EditCategories()
        {
            var categories = await _categoryService.GetCategoriesAsync();

            CategoryListWithChosenCategory model = new CategoryListWithChosenCategory
            {
                Categories = categories.ToList(),
                IsRequired = false
            };

            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> DeleteCategory(int id)
        {
            await _categoryService.DeleteCategoryAsync(id);

            var categories = await _categoryService.GetCategoriesAsync();

            CategoryListWithChosenCategory model = new CategoryListWithChosenCategory
            {
                Categories = categories.ToList(),
                IsRequired = false
            };

            return(PartialView("_EditCategoryList", model));
        }
Пример #3
0
        public async Task <IActionResult> EditCategory(int categoryId, string newName)
        {
            var category = new Category()
            {
                Name = newName
            };
            await _categoryService.UpdateCategoryAsync(categoryId, category);

            var categories = await _categoryService.GetCategoriesAsync();

            CategoryListWithChosenCategory model = new CategoryListWithChosenCategory
            {
                Categories = categories.ToList(),
                IsRequired = false
            };

            return(PartialView("_EditCategoryList", model));
        }
Пример #4
0
        public async Task <IActionResult> AddCategory(string newCategoryName, int?parentId)
        {
            var newCategory = new Category()
            {
                Name = newCategoryName, ParentCategoryId = parentId
            };
            await _categoryService.AddCategoryAsync(newCategory);

            var categories = await _categoryService.GetCategoriesAsync();

            CategoryListWithChosenCategory model = new CategoryListWithChosenCategory
            {
                Categories = categories.ToList(),
                IsRequired = false
            };

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