示例#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();
     }
 }
 public MusicalDirector GetDirector()
 {
     using (DbContext context = new DbContext())
     {
         return context.MusicalDirectors.FirstOrDefault();
     }
 }
 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();
     }
 }
 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();
     }
 }
 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();
     }
 }