public async Task Handle(UpdateParticipantStatusAndRoomCommand command) { var conference = await _context.Conferences .Include(x => x.Rooms).ThenInclude(x => x.RoomEndpoints) .Include(x => x.Rooms).ThenInclude(x => x.RoomParticipants) .Include(x => x.Participants).ThenInclude(x => x.CurrentConsultationRoom).ThenInclude(x => x.RoomParticipants) .Include(x => x.Participants).ThenInclude(x => x.CurrentConsultationRoom).ThenInclude(x => x.RoomEndpoints) .SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var participant = conference.GetParticipants().SingleOrDefault(x => x.Id == command.ParticipantId); if (participant == null) { throw new ParticipantNotFoundException(command.ParticipantId); } var transferToRoom = await GetTransferToConsultationRoom(command).ConfigureAwait(true); transferToRoom?.AddParticipant(new RoomParticipant(participant.Id)); participant.UpdateParticipantStatus(command.ParticipantState); participant.UpdateCurrentRoom(command.Room); participant.UpdateCurrentConsultationRoom(transferToRoom); await _context.SaveChangesAsync(); }
public async Task Handle(UpdateEndpointCommand command) { var conference = await _context.Conferences.Include(x => x.Endpoints) .SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var endpoint = conference.GetEndpoints().SingleOrDefault(x => x.SipAddress == command.SipAddress); if (endpoint == null) { throw new EndpointNotFoundException(command.SipAddress); } if (!string.IsNullOrWhiteSpace(command.DisplayName)) { endpoint.UpdateDisplayName(command.DisplayName); } if (!string.IsNullOrWhiteSpace(command.DefenceAdvocate)) { endpoint.AssignDefenceAdvocate(command.DefenceAdvocate); } await _context.SaveChangesAsync(); }
public async Task Handle(SaveEventCommand command) { var @event = MapCommandToEvent(command); await _context.Events.AddAsync(@event); await _context.SaveChangesAsync(); }
public async Task Handle(UpdateParticipantDetailsCommand command) { var conference = await _context.Conferences.Include("Participants").SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var participant = conference.GetParticipants().SingleOrDefault(x => x.Id == command.ParticipantId); if (participant == null) { throw new ParticipantNotFoundException(command.ParticipantId); } participant.Name = command.Fullname; participant.FirstName = command.FirstName; participant.LastName = command.LastName; participant.DisplayName = command.DisplayName; participant.Representee = command.Representee; participant.ContactEmail = command.ContactEmail; participant.ContactTelephone = command.ContactTelephone; await _context.SaveChangesAsync(); }
public async Task SeedHeartbeats(IEnumerable <Heartbeat> heartbeats) { await using var db = new VideoApiDbContext(_dbContextOptions); await db.Heartbeats.AddRangeAsync(heartbeats); await db.SaveChangesAsync(); }
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(); }
private async Task <LeaveConsultationRequest> SetupLeaveConsultationRequest(bool inConsultationRoom) { var request = new LeaveConsultationRequest { ConferenceId = _context.Test.Conference.Id, ParticipantId = _context.Test.Conference.Participants[0].Id }; if (!inConsultationRoom) { return(request); } var participantId = _context.Test.Conference.Participants[0].Id; await using (var db = new VideoApiDbContext(_context.VideoBookingsDbContextOptions)) { var conference = await db.Conferences .Include("Participants") .SingleAsync(x => x.Id == _context.Test.Conference.Id); var room = new ConsultationRoom(_context.Test.Conference.Id, "TestRoom", VirtualCourtRoomType.Participant, false); var participant = conference.Participants.Single(x => x.Id == participantId); participant.UpdateCurrentRoom(RoomType.ConsultationRoom); participant.UpdateCurrentConsultationRoom(room); await db.SaveChangesAsync(); request.ParticipantId = participantId; } return(request); }
public async Task RemoveEvents() { await using var db = new VideoApiDbContext(_dbContextOptions); var eventsToDelete = db.Events.Where(x => x.Reason.StartsWith("Automated")); db.Events.RemoveRange(eventsToDelete); await db.SaveChangesAsync(); }
public async Task Handle(RemoveHeartbeatsForConferencesCommand command) { var expiredConferences = _context.Conferences.Where(c => c.ScheduledDateTime <= DateTime.UtcNow.AddDays(-14)).Select(c => c.Id); var expiredHeartbeats = await _context.Heartbeats.Where(x => expiredConferences.Contains(x.ConferenceId)).ToListAsync(); _context.RemoveRange(expiredHeartbeats); await _context.SaveChangesAsync(); }
public async Task RemoveHeartbeats(Guid conferenceId, Guid participantId) { await using var db = new VideoApiDbContext(_dbContextOptions); var toDelete = db.Heartbeats.Where(x => x.ConferenceId == conferenceId && x.ParticipantId == participantId); db.Heartbeats.RemoveRange(toDelete); await db.SaveChangesAsync(); }
public async Task RemoveRooms(Guid conferenceId) { await using var db = new VideoApiDbContext(_dbContextOptions); var roomsToDelete = db.Rooms.Include(x => x.RoomParticipants).Where(x => x.ConferenceId == conferenceId); db.Rooms.RemoveRange(roomsToDelete); await db.SaveChangesAsync(); }
public async Task RemoveAlerts(Guid conferenceId) { await using var db = new VideoApiDbContext(_dbContextOptions); var toDelete = db.Tasks.Where(x => x.ConferenceId == conferenceId); db.Tasks.RemoveRange(toDelete); await db.SaveChangesAsync(); }
public async Task Handle(RemoveInstantMessagesForConferenceCommand command) { var instantMessages = await _context.InstantMessages.Where(x => x.ConferenceId == command.ConferenceId).ToListAsync(); _context.RemoveRange(instantMessages); await _context.SaveChangesAsync(); }
public async Task <ConsultationRoom> SeedRoom(ConsultationRoom consultationRoom) { await using var db = new VideoApiDbContext(_dbContextOptions); await db.Rooms.AddAsync(consultationRoom); await db.SaveChangesAsync(); return(consultationRoom); }
public async Task <Conference> SeedConference(Conference conference) { await using var db = new VideoApiDbContext(_dbContextOptions); await db.Conferences.AddAsync(conference); await db.SaveChangesAsync(); return(conference); }
public async Task <List <Room> > SeedRooms(IEnumerable <Room> rooms) { await using var db = new VideoApiDbContext(_dbContextOptions); var seedRooms = rooms.ToList(); await db.Rooms.AddRangeAsync(seedRooms); await db.SaveChangesAsync(); return(seedRooms); }
public async System.Threading.Tasks.Task Handle(AddInstantMessageCommand command) { var @instantMessage = new InstantMessage(command.From, command.MessageText, command.To) { ConferenceId = command.ConferenceId }; await _context.AddAsync(@instantMessage); await _context.SaveChangesAsync(); }
public async Task <List <Alert> > SeedAlerts(IEnumerable <Alert> alerts) { await using var db = new VideoApiDbContext(_dbContextOptions); var seedAlerts = alerts.ToList(); await db.Tasks.AddRangeAsync(seedAlerts); await db.SaveChangesAsync(); return(seedAlerts); }
public async Task RemoveHeartbeats(List <Conference> conferences) { var conferenceIds = conferences.Select(conference => conference.Id).ToList(); await using var db = new VideoApiDbContext(_dbContextOptions); var heartbeats = await db.Heartbeats .Where(x => conferenceIds.Contains(x.ConferenceId)) .ToListAsync(); db.RemoveRange(heartbeats); await db.SaveChangesAsync(); }
public async Task Handle(AddParticipantToParticipantRoomCommand command) { var room = await _context.Rooms.OfType <ParticipantRoom>().SingleOrDefaultAsync(x => x.Id == command.RoomId); if (room == null) { throw new RoomNotFoundException(command.RoomId); } room.AddParticipant(new RoomParticipant(command.ParticipantId)); await _context.SaveChangesAsync(); }
public async Task GivenNoConsultationRoomsAreAvailable() { await using var db = new VideoApiDbContext(_context.VideoBookingsDbContextOptions); var conference = await db.Conferences .Include("Participants") .SingleAsync(x => x.Id == _context.Test.Conference.Id); conference.Participants[0].UpdateCurrentRoom(RoomType.ConsultationRoom1); conference.Participants[1].UpdateCurrentRoom(RoomType.ConsultationRoom2); await db.SaveChangesAsync(); }
public async Task Handle(UpdateParticipantRoomConnectionDetailsCommand command) { var room = await _context.Rooms.OfType <ParticipantRoom>() .SingleOrDefaultAsync(x => x.ConferenceId == command.ConferenceId && x.Id == command.RoomId); if (room == null) { throw new RoomNotFoundException(command.ConferenceId, command.Label); } room.UpdateConnectionDetails(command.Label, command.IngestUrl, command.PexipNode, command.ParticipantUri); await _context.SaveChangesAsync(); }
public async Task Handle(UpdateConferenceStatusCommand command) { var conference = await _context.Conferences .SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } conference.UpdateConferenceStatus(command.ConferenceState); await _context.SaveChangesAsync(); }
public async Task SeedRoomWithRoomParticipant(long roomId, RoomParticipant roomParticipant) { await using var db = new VideoApiDbContext(_dbContextOptions); var room = db.Rooms.Include(x => x.RoomParticipants).First(x => x.Id == roomId); room.AddParticipant(roomParticipant); var participant = await db.Participants.FindAsync(roomParticipant.ParticipantId); participant.CurrentConsultationRoomId = roomId; await db.SaveChangesAsync(); }
public async Task Handle(UpdateTaskCommand command) { var task = _context.Tasks .SingleOrDefault(x => x.Id == command.TaskId && x.ConferenceId == command.ConferenceId); if (task == null) { throw new TaskNotFoundException(command.ConferenceId, command.TaskId); } task.CompleteTask(command.UpdatedBy); await _context.SaveChangesAsync(); }
public async Task Handle(SaveEventCommand command) { var @event = new Event(command.ConferenceId, command.ExternalEventId, command.EventType, command.ExternalTimestamp, command.TransferredFrom, command.TransferredTo, command.Reason, command.Phone) { ParticipantId = command.ParticipantId, EndpointFlag = command.IsEndpoint }; await _context.Events.AddAsync(@event); 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); }
public async Task Handle(AddTaskCommand command) { var conference = await _context.Conferences.SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } var task = new Domain.Task(command.ConferenceId, command.OriginId, command.Body, command.TaskType); await _context.Tasks.AddAsync(task); await _context.SaveChangesAsync(); }
public async Task Handle(UpdateMeetingRoomCommand command) { var conference = await _context.Conferences.SingleOrDefaultAsync(x => x.Id == command.ConferenceId); if (conference == null) { throw new ConferenceNotFoundException(command.ConferenceId); } conference.UpdateMeetingRoom(command.AdminUri, command.JudgeUri, command.ParticipantUri, command.PexipNode, command.TelephoneConferenceId); await _context.SaveChangesAsync(); }
public async Task GivenTheJudgeIsInTheConsultationRoom() { var conference = _context.Test.Conference; var room = _context.Test.Room; await using var db = new VideoApiDbContext(_context.VideoBookingsDbContextOptions); var judge = conference.Participants.Single(x => x.IsJudge()); var dbRoom = await db.Rooms.Include(x => x.RoomParticipants).SingleAsync(x => x.Label == room.Label); dbRoom.AddParticipant(new RoomParticipant(judge.Id)); var record = await db.SaveChangesAsync(); record.Should().BePositive(); }