private void DeleteConference(int id) { using (var context = new EFContext()) { var conf = context.Conferences.SingleOrDefault(e => e.Id == id); context.Conferences.Remove(conf); context.SaveChanges(); } }
private void AddOrReplaceConference(Conference conference) { using (var context = new EFContext()) { if (conference.Id == default(int)) { // Add Scenario context.Conferences.Add(conference); context.SaveChanges(); SendEmailNotificationAboutNewConference(conference); } else { // Update Scenario conference = context.Conferences.Attach(conference); context.Entry(conference).State = System.Data.EntityState.Modified; context.SaveChanges(); } } }