コード例 #1
0
        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);
        }
コード例 #2
0
 public void SaveCategory(ResourceCategory category)
 {
     if (category.ID == 0)
     {
         context.ResourceCategories.Add(category);
     }
     else
     {
         context.Entry(category).State = EntityState.Modified;
     }
     context.SaveChanges();
 }