コード例 #1
0
 public Gig Get(int id)
 {
     using (DbContext context = new DbContext())
     {
         return context.Gigs.FirstOrDefault(g => g.Id == id);
     }
 }
コード例 #2
0
 public IEnumerable<Gig> List()
 {
     using (DbContext context = new DbContext())
     {
         return context.Gigs.ToList();
     }
 }
コード例 #3
0
 public MusicalDirector GetDirector()
 {
     using (DbContext context = new DbContext())
     {
         return context.MusicalDirectors.FirstOrDefault();
     }
 }
コード例 #4
0
 public Band GetBand()
 {
     using (DbContext context = new DbContext())
     {
         return context.Bands.FirstOrDefault();
     }
 }
コード例 #5
0
 public void Add(Gig gig)
 {
     using (DbContext context = new DbContext())
     {
         context.Gigs.Add(gig);
         context.SaveChanges();
     }
 }
コード例 #6
0
 public void Update(Gig gig)
 {
     using (DbContext context = new DbContext())
     {
         context.Entry(gig).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #7
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();
     }
 }
コード例 #8
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();
     }
 }
コード例 #9
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();
     }
 }