public void AddJournal(Journal journal) { using (var presseContext = new PresseDataContext()) { if (presseContext.Journaux.Count() == 0) { presseContext.Journaux.InsertOnSubmit(journal); } else { foreach (Journal j in presseContext.Journaux) { if (j.Nom != journal.Nom) { presseContext.Journaux.InsertOnSubmit(journal); } else { Messenger.Default.Send(WindowMessages.ErreurInsert); } } } presseContext.SubmitChanges(); } }
public void UpdateJournal(Journal journal) { using (var presseContext = new PresseDataContext()) { var journalQuery = from b in presseContext.Journaux where b.Id == journal.Id select b; var journaldel = journalQuery.First(); presseContext.Journaux.DeleteOnSubmit(journaldel); presseContext.Journaux.InsertOnSubmit(journal); presseContext.SubmitChanges(); } }