private void UpdateAnn(CL_Annonce newAnn) { CL_Annonce annInDb = (from CL_Annonce _ann in ClarolineDB.Annonces_Table where _ann.Equals(AllAnnonces[AllAnnonces.IndexOf(newAnn)]) select _ann).First(); annInDb.notifiedDate = newAnn.notifiedDate; AllAnnonces[AllAnnonces.IndexOf(annInDb)].notifiedDate = newAnn.notifiedDate; annInDb.updated = newAnn.updated; AllAnnonces[AllAnnonces.IndexOf(annInDb)].updated = newAnn.updated; if (annInDb.date.CompareTo(newAnn.date) < 0) { annInDb.date = newAnn.date; AllAnnonces[AllAnnonces.IndexOf(annInDb)].date = newAnn.date; } annInDb.content = newAnn.content; AllAnnonces[AllAnnonces.IndexOf(annInDb)].content = newAnn.content; annInDb.upToDateContent = newAnn.upToDateContent; AllAnnonces[AllAnnonces.IndexOf(annInDb)].upToDateContent = newAnn.upToDateContent; ClarolineDB.SubmitChanges(); AddNotification(CL_Notification.CreateNotification(annInDb, true)); }
public void DeleteAnnonce(CL_Annonce annForDelete) { // Remove the cours item from the "all" observable collection. AllAnnonces.Remove(annForDelete); AnnByCours[annForDelete.Cours.sysCode].Remove(annForDelete); // Remove the cours item from the data context. ClarolineDB.Annonces_Table.DeleteOnSubmit(annForDelete); // Save changes to the database. ClarolineDB.SubmitChanges(); }
public void AddAnnonce(CL_Annonce newAnn) { newAnn.updated = true; if (!AllAnnonces.Contains(newAnn)) { // Add a to-do item to the data context. ClarolineDB.Annonces_Table.InsertOnSubmit(newAnn); // Save changes to the database. ClarolineDB.SubmitChanges(); // Add a to-do item to the "all" observable collection. AllAnnonces.Add(newAnn); AddNotification(CL_Notification.CreateNotification(newAnn, false)); } else UpdateAnn(newAnn); }