public async Task Handle(RemoveConferenceCommand command) { var conference = await _context.Conferences .Include("Endpoints") .Include("Participants.ParticipantStatuses") .Include(x => x.Participants).ThenInclude(x => x.LinkedParticipants) .Include("ConferenceStatuses") .Include(x => x.Participants).ThenInclude(x => x.TestCallResult) .SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var events = await _context.Events.Where(x => x.ConferenceId == conference.Id).ToListAsync(); var tasks = await _context.Tasks.Where(x => x.ConferenceId == conference.Id).ToListAsync(); _context.Remove(conference); _context.RemoveRange(events); _context.RemoveRange(tasks); await _context.SaveChangesAsync(); }
public async Task RemoveConference(Guid conferenceId) { await using var db = new VideoApiDbContext(_dbContextOptions); var conference = await db.Conferences .Include("Endpoints") .Include("Participants.ParticipantStatuses") .Include("ConferenceStatuses") .SingleAsync(x => x.Id == conferenceId); db.Remove(conference); await db.SaveChangesAsync(); await RemoveAlerts(conferenceId); }