public async Task <IActionResult> AssignCategory(int id, [FromServices] ICategoryApiService categoryApiService)
        {
            TempData["active"] = "blog";

            var categories = await categoryApiService.GetAllAsync();

            var blogCategories = await _blogApiService.GetCategories(id);

            TempData["blogId"] = id;

            List <AssignCategoryModel> list = new List <AssignCategoryModel>();

            foreach (var category in categories)
            {
                AssignCategoryModel model = new AssignCategoryModel();

                model.CategoryId   = category.Id;
                model.CategoryName = category.Name;
                model.Exists       = blogCategories.Contains(category);

                list.Add(model);
            }

            return(View(list));
        }
예제 #2
0
        public async Task <IActionResult> AssignCategory(int id,
                                                         [FromServices] ICategoryApiService categoryApiService)
        {
            TempData["active"] = "topic";
            var categories = await categoryApiService.GetAllAsync();

            var topicCategories = (await _topicApiService.GetCategoriesAsync(id));

            TempData["topicId"] = id;

            List <AssignCategoryModel> list = new List <AssignCategoryModel>();

            foreach (var item in categories)
            {
                AssignCategoryModel model = new AssignCategoryModel();
                model.CategoryId   = item.Id;
                model.CategoryName = item.Name;
                model.Exist        = topicCategories.Contains(item);

                list.Add(model);
            }

            return(View(list));
        }
 public async Task <IActionResult> Index()
 {
     TempData["active"] = "category";
     return(View(await _categoryApiService.GetAllAsync()));
 }
예제 #4
0
 public async Task <IActionResult> Index()
 {
     return(View(await _categoryApiService.GetAllAsync()));
 }
예제 #5
0
 public IViewComponentResult Invoke()
 {
     return(View(_categoryApiService.GetAllAsync().Result));
 }