public ResourceCategory DeleteCategory(int categoryId) { ResourceCategory dbEntry = context.ResourceCategories.FirstOrDefault(r => r.ID == categoryId); if (dbEntry != null) { context.ResourceCategories.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void SaveCategory(ResourceCategory category) { if (category.ID == 0) { context.ResourceCategories.Add(category); } else { context.Entry(category).State = EntityState.Modified; } context.SaveChanges(); }