Ejemplo n.º 1
0
        public async Task <IActionResult> AssignCategory(int id, [FromServices] ICategoryApiService categoryApiService)
        {
            TempData["active"] = "blog";
            var categories = await categoryApiService.GetAllAsync();

            var blogCategories = await _blogApiService.GetCategoriesAsync(id);

            TempData["blogId"] = id;

            // GetRolesAsync() IList<string>

            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));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AssignCategory(int id, [FromServices] ICategoryApiService categoryApiService)
        {
            TempData["active"] = "blog";
            var categories = await categoryApiService.GetAllAsync();

            //var blogCategories = (await _blogApiService.GetCategoriesAsync(id)).Select(I=>I.Name).ToList();
            var blogCategories = await _blogApiService.GetCategoriesAsync(id);

            TempData["blogId"] = 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.Exists       = blogCategories.Contains(item);

                list.Add(model);
            }
            return(View(list));
        }