Example #1
0
        public async Task Handle(CreateVideoHearingCommand command)
        {
            var videoHearing = new VideoHearing(command.CaseType, command.HearingType, command.ScheduledDateTime,
                                                command.ScheduledDuration, command.Venue, command.HearingRoomName,
                                                command.OtherInformation, command.CreatedBy, command.QuestionnaireNotRequired,
                                                command.AudioRecordingRequired, command.CancelReason);

            _context.VideoHearings.Add(videoHearing);

            await _hearingService.AddParticipantToService(videoHearing, command.Participants);

            videoHearing.AddCases(command.Cases);

            await _context.SaveChangesAsync();

            command.NewHearingId = videoHearing.Id;
        }
Example #2
0
        public async Task Handle(CreateVideoHearingCommand command)
        {
            var videoHearing = new VideoHearing(command.CaseType, command.HearingType, command.ScheduledDateTime,
                                                command.ScheduledDuration, command.Venue, command.HearingRoomName,
                                                command.OtherInformation, command.CreatedBy, command.QuestionnaireNotRequired,
                                                command.AudioRecordingRequired, command.CancelReason);

            // denotes this hearing is cloned
            if (command.SourceId.HasValue)
            {
                videoHearing.SourceId = command.SourceId;
            }

            await _context.VideoHearings.AddAsync(videoHearing);

            var participants = await _hearingService.AddParticipantToService(videoHearing, command.Participants);

            await _hearingService.CreateParticipantLinks(participants, command.LinkedParticipants);

            videoHearing.AddCases(command.Cases);

            if (command.Endpoints != null && command.Endpoints.Count > 0)
            {
                var dtos         = command.Endpoints;
                var newEndpoints = (from dto in dtos
                                    let defenceAdvocate =
                                        DefenceAdvocateHelper.CheckAndReturnDefenceAdvocate(dto.DefenceAdvocateUsername,
                                                                                            videoHearing.GetParticipants())
                                        select new Endpoint(dto.DisplayName, dto.Sip, dto.Pin, defenceAdvocate)).ToList();

                videoHearing.AddEndpoints(newEndpoints);
            }

            await _context.SaveChangesAsync();

            command.NewHearingId = videoHearing.Id;
        }