public Gig Get(int id) { using (DbContext context = new DbContext()) { return context.Gigs.FirstOrDefault(g => g.Id == id); } }
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(); } }
public void Add(Gig gig) { using (DbContext context = new DbContext()) { context.Gigs.Add(gig); context.SaveChanges(); } }
public void Update(Gig gig) { using (DbContext context = new DbContext()) { context.Entry(gig).State = EntityState.Modified; context.SaveChanges(); } }
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(); } }