コード例 #1
0
ファイル: EFRepository.cs プロジェクト: GStephensjr/Projects
        public void deleteEntry(HeadquartersAF entry)
        {
            HeadquartersAF dbEntry = context.HeadquartersAF.FirstOrDefault(p => p == entry);

            context.HeadquartersAF.Remove(dbEntry);
            context.SaveChanges();
        }
コード例 #2
0
ファイル: EFRepository.cs プロジェクト: GStephensjr/Projects
 public void saveEntry(HeadquartersAF entry)
 {
     if (context.HeadquartersAF.Any(c => c.StaffName == entry.StaffName))
     {
         HeadquartersAF dbEntry = context.HeadquartersAF
                                  .FirstOrDefault(p => p.StaffName == entry.StaffName);
         if (dbEntry != null)
         {
             dbEntry.StaffName      = entry.StaffName;
             dbEntry.Location       = entry.Location;
             dbEntry.Commander      = entry.Commander;
             dbEntry.Mission        = entry.Mission;
             dbEntry.CommanderTitle = entry.CommanderTitle;
         }
     }
     else
     {
         context.HeadquartersAF.Add(entry);
     }
     context.SaveChanges();
 }