protected void DatabaseInitialization()
 {
     if (_repository.Categories.Any()) return;
     for (var i = 0; i < 15; i++)
     {
         var cat = new Category();
         var random = new Random();
         var randomnext = random.Next(2, 5);
         cat.CategoryName = String.Format("LeftMenu номер {0}", i);
         for (var j = 0; j < randomnext; j++)
         {
             var sub = new Subcategory { SubcategoryName = String.Format("TopMenu номер {0}", j) };
             cat.Subcatigories.Add(sub);
         }
         _repository.SaveCategory(cat);
     }
 }
 public void DeleteSubcategory(Subcategory subcategories)
 {
     _context.Subcategories.Remove(subcategories);
     _context.SaveChanges();
 }
 public void SaveSubcategory(Subcategory subcategories)
 {
     if (subcategories.SubcategoryId == 0)
     {
         _context.Subcategories.Add(subcategories);
     }
     _context.SaveChanges();
 }