public void UpdateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                var a = db.Announcements.Find(announcement.ID);

                if (a == null) throw new ArgumentException("Announcement not found");

                a.Title = announcement.Title;
                a.Content = announcement.Content;
                a.PublishDate = announcement.PublishDate;

                db.SaveChanges();
            }
        }
        public void CreateAnnouncement(Announcement announcement)
        {
            using (var db = new CC.Data.CCDB())
            {
                Data.Announcement a = new Data.Announcement()
                {
                    Event_ID = announcement.EventID,
                    Title = announcement.Title,
                    Content = announcement.Content,
                    PublishDate = announcement.PublishDate
                };

                db.Announcements.Add(a);

                db.SaveChanges();
            }
        }
Beispiel #3
0
        public static Announcement Map(this Data.Announcement a)
        {
            Announcement announcement = new Announcement
            {
                ID = a.ID,
                EventID = a.Event_ID,
                Title = a.Title,
                Content = a.Content,
                PublishDate = a.PublishDate
            };

            return announcement;
        }