예제 #1
0
 public void Update(Gig gig)
 {
     using (DbContext context = new DbContext())
     {
         context.Entry(gig).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #2
0
 public void Delete(int id)
 {
     using (DbContext context = new DbContext())
     {
         Gig gig = context.Gigs.FirstOrDefault(g => g.Id == id);
         context.Entry(gig).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
예제 #3
0
 public void Save(MusicalDirector director)
 {
     using (DbContext context = new DbContext())
     {
         if (context.MusicalDirectors.Any())
         {
             context.Entry(director).State = EntityState.Modified;
         }
         else
         {
             context.MusicalDirectors.Add(director);
         }
         context.SaveChanges();
     }
 }
예제 #4
0
 public void Save(Band band)
 {
     using (DbContext context = new DbContext())
     {
         if (context.Bands.Any())
         {
             context.Entry(band).State = EntityState.Modified;
         }
         else
         {
             context.Bands.Add(band);
         }
         context.SaveChanges();
     }
 }