public void RemoveAdvertisementAndSaveAllChanges(Advertisement advertisement) { if (Advertisements.All(adv => adv.IdAdvertisement != advertisement.IdAdvertisement)) { throw new RepositoryHasNotThisItemException(); } advertisements.Remove(advertisement); }
public Advertisement CreateAdvertisement(Advertisement advertisement) { if (advertisement.IdAdvertisement != 0) { throw new CreatedObjectIsNotEmptyException(); } advertisement.IdAdvertisement = advertisements.Count; advertisements.Add(advertisement); return advertisement; }
public Advertisement CreateAdvertisement(Advertisement advertisement) { if (advertisement.IdAdvertisement != 0) { throw new CreatedObjectIsNotEmptyException(); } db.Advertisements.Add(advertisement); db.SaveChanges(); return advertisement; }