public void DeleteActivity(int StudentId, int ActivityId)
        {
            StudentsActivities sa = _context.StudentsActivities.Include(a => a.Activity).First(a => a.StudentId == StudentId && a.ActivityId == ActivityId);
            Activities         ac = sa.Activity;

            _context.Remove(sa);
            _context.Remove(ac);
            _context.SaveChanges();
        }
Example #2
0
        public void RemoveAd(int AdId)
        {
            var Ad = _context.Ads.Include(a => a.Periods).First(a => a.AdId == AdId);

            foreach (var period in Ad.Periods)
            {
                _context.Remove(period);
            }
            _context.SaveChanges();
            _context.Ads.Remove(Ad);
            _context.SaveChanges();
        }