コード例 #1
0
        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));
        }
コード例 #3
0
 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));
 }