public void DeleteAnnouncement(Guid ID) { Models.DBObjects.Announcement announcementToDelete = dbContext.Announcements.FirstOrDefault(x => x.IDAnnouncement == ID); if (announcementToDelete != null) { dbContext.Announcements.DeleteOnSubmit(announcementToDelete); dbContext.SubmitChanges(); } }
public void UpdateAnnouncement(AnnouncementModel announcementModel) { Models.DBObjects.Announcement existingannouncement = dbContext.Announcements.FirstOrDefault(x => x.IDAnnouncement == announcementModel.IDAnnouncement); if (existingannouncement != null) { existingannouncement.UpdateObject(announcementModel); dbContext.SubmitChanges(); } }
public AnnouncementModel GetAnnouncementByID(Guid id) { Models.DBObjects.Announcement existingAnnouncement = dbContext.Announcements.FirstOrDefault(x => x.IDAnnouncement == id); if (existingAnnouncement != null) { return(existingAnnouncement.MapObject <AnnouncementModel>()); } else { return(null); } }
public void UpdateAnnouncement(AnnouncementModel announcementModel) { Models.DBObjects.Announcement existingAnnouncement = clubmembershipDataContext.Announcements.FirstOrDefault (x => x.IDAnnouncement == announcementModel.IDAnnouncement); if (existingAnnouncement != null) { existingAnnouncement.IDAnnouncement = announcementModel.IDAnnouncement; existingAnnouncement.ValidFrom = announcementModel.ValidFrom; existingAnnouncement.ValidTo = announcementModel.ValidTo; existingAnnouncement.Title = announcementModel.Title; existingAnnouncement.Text = announcementModel.Text; existingAnnouncement.EventDateTime = announcementModel.EventDateTime; existingAnnouncement.Tags = announcementModel.Tags; clubmembershipDataContext.SubmitChanges(); } }