private async Task <List <CategorySimpleModel> > PrepareSubCategorySimpleModels(int currentCategoryId, bool loadSubCategories)
        {
            var result = new List <CategorySimpleModel>();

            var allSubCategories = await _subCategoryService.GetAllSubCategories();

            var subCategories = allSubCategories.Where(c => c.CategoryId == currentCategoryId).ToList();

            foreach (var subCategory in subCategories)
            {
                var categoryModel = new CategorySimpleModel
                {
                    Id               = subCategory.CategoryId,
                    Name             = subCategory.SubCategoryName,
                    SeName           = subCategory.SubCategoryName,
                    IncludeInTopMenu = true
                };

                //number of products in each category
                categoryModel.NumberOfProducts = 5;

                result.Add(categoryModel);
            }

            return(result);
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            model.MenuItem = await menuItemService.GetMenuItemById(id.Value);

            model.SubCategories = await subCategoryService.GetAllSubCategories();

            if (model.MenuItem == null)
            {
                return(NotFound());
            }
            return(View(model));
        }
 public async Task <IActionResult> Index()
 {
     return(View(await subCategoryService.GetAllSubCategories()));
 }
Exemple #4
0
 // GET: Admin/SubCategoryOne/Create
 public async Task <IActionResult> Create()
 {
     //ViewBag.FKCategoryId = new SelectList(objCategoryBO.GetCategories(true), "PKCategoryId", "CategoryName");
     ViewBag.SubCategoryId = new SelectList(await _subCategoryService.GetAllSubCategories(), "SubCategoryOneId", "SubCategoryName");
     return(View());
 }