public async Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Categories.Any())
            {
                return;
            }

            var categoriesAndProductsData = CategoriesData.GetCategories();
            await dbContext.Categories.AddRangeAsync(categoriesAndProductsData);
        }
示例#2
0
 public ProductsCategoryViewModel(INavigation navigation)
 {
     _categoriesData      = new CategoriesData();
     CategoriesCollection = _categoriesData.GetCategories();
     _navigation          = navigation;
 }
 //Get Categories
 public JsonResult GetCategories( )
 {
     return(Json(CategoryData.GetCategories(), JsonRequestBehavior.AllowGet));
 }