public void PutAnnouncement(int id, Announcement announcement) { announcement.id = id; if (!repository.Update(announcement)) { throw new ArgumentNullException("Opps ! There is no announcement with id #" + id + " !"); } }
public void Post(Announcement newAnnouncement) { if (newAnnouncement == null) { throw new ArgumentNullException("Opps ! Announcement object is null that was sended !"); } newAnnouncement.id = _nextId++; announcements.Add(newAnnouncement); }
public bool Update(Announcement updatedAnnouncement) { if (updatedAnnouncement == null) { throw new ArgumentNullException("Opps ! Announcement object is null that was sended !"); } else { var announcement = this.Get(updatedAnnouncement.id); if (announcement.id == -1) { return false; } announcement.Title = updatedAnnouncement.Title; announcement.Content = updatedAnnouncement.Content; return true; } }
public void PostAnnouncement(Announcement newAnnouncement) { repository.Post(newAnnouncement); }