Пример #1
0
        public void deleteEntry(Squadron entry)
        {
            Squadron dbEntry = context.Squadrons.FirstOrDefault(p => p == entry);

            context.Squadrons.Remove(dbEntry);
            context.SaveChanges();
        }
Пример #2
0
 public void saveEntry(Squadron entry)
 {
     if (context.Squadrons.Any(c => c.Name == entry.Name))
     {
         Squadron dbEntry = context.Squadrons
                            .FirstOrDefault(p => p.Name == entry.Name);
         if (dbEntry != null)
         {
             dbEntry.Name      = entry.Name;
             dbEntry.Location  = entry.Location;
             dbEntry.Commander = entry.Commander;
             dbEntry.Mission   = entry.Mission;
             dbEntry.Size      = entry.Size;
             dbEntry.Motto     = entry.Motto;
         }
     }
     else
     {
         context.Squadrons.Add(entry);
     }
     context.SaveChanges();
 }