public List<GoodCategory> GetAllCategories() { using (var context = new EntitiesContext()) { var categories = context.GoodCategories.ToList(); CreateTree(categories); return categories; } }
public void CreateGoodCategory(GoodCategoryViewModel model) { using (var context = new EntitiesContext()) { var newCategory = new GoodCategory { Name = model.Name }; context.GoodCategories.Add(newCategory); context.SaveChanges(); } }