コード例 #1
0
        public Eavent DeleteEavent(int eaventID)
        {
            Eavent dbEntry = context.Eavents
                             .FirstOrDefault(p => p.EaventID == eaventID);

            if (dbEntry != null)
            {
                context.Eavents.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
コード例 #2
0
 public void SaveEavent(Eavent eavent)
 {
     if (eavent.EaventID == 0)
     {
         context.Eavents.Add(eavent);
     }
     else
     {
         Eavent dbEntry = context.Eavents
                          .FirstOrDefault(p => p.EaventID == eavent.EaventID);
         if (dbEntry != null)
         {
             dbEntry.Name     = eavent.Name;
             dbEntry.Category = eavent.Category;
         }
     }
     context.SaveChanges();
 }