public void UpdateCategory(int catId, Category category) { var itemToUpdate = dbContext.Categories.SingleOrDefault(x => x.CategoryId == catId); if (itemToUpdate != null) { itemToUpdate = category; dbContext.SaveChanges(); } }
public void AddNewCategory(Category category) { dbContext.Categories.Add(category); dbContext.SaveChanges(); }