예제 #1
0
        public void RemoveAdvertisementAndSaveAllChanges(Advertisement advertisement)
        {
            if (Advertisements.All(adv => adv.IdAdvertisement != advertisement.IdAdvertisement))
            {
                throw new RepositoryHasNotThisItemException();
            }

            advertisements.Remove(advertisement);
        }
예제 #2
0
        public Advertisement CreateAdvertisement(Advertisement advertisement)
        {
            if (advertisement.IdAdvertisement != 0)
            {
                throw new CreatedObjectIsNotEmptyException();
            }

            advertisement.IdAdvertisement = advertisements.Count;
            advertisements.Add(advertisement);
            return advertisement;
        }
예제 #3
0
        public Advertisement CreateAdvertisement(Advertisement advertisement)
        {
            if (advertisement.IdAdvertisement != 0)
            {
                throw new CreatedObjectIsNotEmptyException();
            }

            db.Advertisements.Add(advertisement);
            db.SaveChanges();
            return advertisement;
        }