Пример #1
0
 public bool RemoveAnnoucement(Annoucement annoucementToRemove)
 {
     foreach (var atoc in _db.AnnoucementCategory.Where(ac => ac.Annoucement.Id == annoucementToRemove.Id))
     {
         _db.AnnoucementCategory.Remove(atoc);
     }
     _db.Annoucements.Remove(annoucementToRemove);
     return(_db.SaveChanges() > 0);
 }
Пример #2
0
        public bool AddAnnoucement(Annoucement newAnnoucement)
        {
            if (newAnnoucement == null)
            {
                throw new ArgumentNullException(nameof(newAnnoucement));
            }

            _db.Annoucements.Add(newAnnoucement);
            return(_db.SaveChanges() > 0);
        }
Пример #3
0
 public bool SaveAnnoucementChanges(Annoucement editedAnnoucement)
 {
     _db.Entry(editedAnnoucement).State = EntityState.Modified;
     return(_db.SaveChanges() > 0);
 }