public async Task Should_not_add_existing_participant_to_the_same_video_hearing()
        {
            var seededHearing = await Hooks.SeedVideoHearing();

            TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}");
            _newHearingId = seededHearing.Id;
            var representative =
                (Representative)seededHearing.GetParticipants().First(x => x.GetType() == typeof(Representative));

            var newParticipant = new NewParticipant()
            {
                Person      = representative.Person,
                CaseRole    = representative.CaseRole,
                HearingRole = representative.HearingRole,
                DisplayName = representative.DisplayName,
                Representee = representative.Representee
            };

            var participants = new List <NewParticipant>()
            {
                newParticipant
            };

            Assert.ThrowsAsync <DomainRuleException>(() => _commandHandler.Handle(
                                                         new AddParticipantsToVideoHearingCommand(_newHearingId, participants, null)));
        }
        private async Task <List <Person> > AddExistingPersonToAHearing(Person existingPerson)
        {
            var seededHearing = await Hooks.SeedVideoHearing();

            var personListBefore = await GetPersonsInDb();

            TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}");
            _newHearingId = seededHearing.Id;

            var caseTypeName = "Generic";
            var caseType     = GetCaseTypeFromDb(caseTypeName);

            var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant");
            var applicantRepresentativeHearingRole =
                applicantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var newParticipant = new NewParticipant()
            {
                Person      = existingPerson,
                CaseRole    = applicantCaseRole,
                HearingRole = applicantRepresentativeHearingRole,
                DisplayName = $"{existingPerson.FirstName} {existingPerson.LastName}",
                Representee = string.Empty
            };

            var participants = new List <NewParticipant>()
            {
                newParticipant
            };

            await _commandHandler.Handle(new AddParticipantsToVideoHearingCommand(_newHearingId, participants, null));

            return(personListBefore);
        }
        public IActionResult RegisterParticipant([FromBody] NewParticipant model)
        {
            logger.LogInformation($"#RegisterParticipant. {model?.Email}, {model?.Name}, {model?.EthAddress}, {model?.Avatar}");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResult.GetResult(ModelState)));
            }

            var state = tournamentService.CheckNewParticipant(model);

            if (!state.IsSuccess)
            {
                return(BadRequest(ErrorResult.GetResult(state)));
            }

            var res = tournamentService.RegisterParticipant(model);

            if (!res.IsSuccess)
            {
                return(BadRequest(ErrorResult.GetResult(res)));
            }

            logger.LogInformation($"#RegisterParticipant. {model?.Email}: OK");
            return(Ok());
        }
        public async Task Should_throw_exception_when_adding_unsupported_role_to_hearing()
        {
            var seededHearing = await Hooks.SeedVideoHearing();

            TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}");
            _newHearingId = seededHearing.Id;
            var representative = (Representative)seededHearing.GetParticipants().First(x => x.GetType() == typeof(Representative));

            representative.HearingRole.UserRole.Name = "NonExistent";
            var newParticipant = new NewParticipant()
            {
                Person      = representative.Person,
                CaseRole    = representative.CaseRole,
                HearingRole = representative.HearingRole,
                DisplayName = representative.DisplayName,
                Reference   = representative.Reference,
                Representee = representative.Representee
            };

            var participants = new List <NewParticipant>()
            {
                newParticipant
            };

            Assert.ThrowsAsync <DomainRuleException>(() => _commandHandler.Handle(
                                                         new AddParticipantsToVideoHearingCommand(_newHearingId, participants)));
        }
        public async Task Should_add_participants_to_video_hearing()
        {
            //Arrange
            var originalParticipantCount = _hearing.GetParticipants().Count;

            var applicantCaseRole = _genericCaseType.CaseRoles.First(x => x.Name == "Applicant");
            var applicantRepresentativeHearingRole =
                applicantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var newPerson      = new PersonBuilder(true).Build();
            var newParticipant = new NewParticipant()
            {
                Person      = newPerson,
                CaseRole    = applicantCaseRole,
                HearingRole = applicantRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Representee = string.Empty
            };

            _newParticipants.Add(newParticipant);
            _command = BuildCommand();

            //Act
            await _handler.Handle(_command);

            var updatedVideoHearing =
                await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(_hearing.Id));

            var newParticipantCount = updatedVideoHearing.GetParticipants().Count;

            //Assert
            newParticipantCount.Should().Be(originalParticipantCount + 1);
        }
        public async Task Should_change_judge()
        {
            //Arrange
            var judgeCaseRole    = _genericCaseType.CaseRoles.First(x => x.Name == "Judge");
            var judgeHearingRole =
                judgeCaseRole.HearingRoles.First(x => x.Name == "Judge");

            var oldJudgeId = _hearing.GetParticipants().SingleOrDefault(x => x.HearingRole.Id == judgeHearingRole.Id).Id;

            var newJudge = new PersonBuilder(true).Build();

            var newParticipant = new NewParticipant()
            {
                Person      = newJudge,
                CaseRole    = judgeCaseRole,
                HearingRole = judgeHearingRole,
                DisplayName = $"{newJudge.FirstName} {newJudge.LastName}"
            };

            _removedParticipantIds.Add(oldJudgeId);
            _newParticipants.Add(newParticipant);
            _command = BuildCommand();

            //Act
            await _handler.Handle(_command);

            var updatedVideoHearing =
                await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(_hearing.Id));

            var addedJudge = updatedVideoHearing.GetParticipants().SingleOrDefault(x => x.HearingRole.Id == judgeHearingRole.Id);

            //Assert
            addedJudge.Person.FirstName.Should().Be(newJudge.FirstName);
            addedJudge.Person.LastName.Should().Be(newJudge.LastName);
        }
        public async Task Should_Add_Participant_With_A_Link()
        {
            var seededHearing = await Hooks.SeedVideoHearing();

            TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}");
            _newHearingId = seededHearing.Id;

            const string caseTypeName = "Generic";
            var          caseType     = GetCaseTypeFromDb(caseTypeName);

            var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant");
            var applicantRepresentativeHearingRole =
                applicantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var respondentCaseRole = caseType.CaseRoles.First(x => x.Name == "Respondent");
            var respondentRepresentativeHearingRole =
                respondentCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var newPerson   = new PersonBuilder(true).Build();
            var newPerson1  = new PersonBuilder(true).Build();
            var interpretee = new NewParticipant()
            {
                Person      = newPerson,
                CaseRole    = applicantCaseRole,
                HearingRole = applicantRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Representee = string.Empty
            };
            var interpreter = new NewParticipant()
            {
                Person      = newPerson1,
                CaseRole    = respondentCaseRole,
                HearingRole = respondentRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Representee = string.Empty
            };
            var participants = new List <NewParticipant>()
            {
                interpretee,
                interpreter
            };
            var links = new List <LinkedParticipantDto>();
            var link  = new LinkedParticipantDto(
                interpreter.Person.ContactEmail,
                interpretee.Person.ContactEmail,
                LinkedParticipantType.Interpreter
                );

            links.Add(link);

            await _commandHandler.Handle(new AddParticipantsToVideoHearingCommand(_newHearingId, participants, links));

            var returnedVideoHearing =
                await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id));

            returnedVideoHearing.Participants.Where(x => x.LinkedParticipants.Any()).Should().NotBeNull();
        }
        public IActionResult AddParticipant([FromBody] NewParticipant newParticipant)
        {
            Event myEvent = eventsService.AddParticipantToEvent(newParticipant);

            if (myEvent == null)
            {
                return(BadRequest("Coś poszło nie tak. Upewnij się, że nie jesteś już zapisany na to wydarzenie."));
            }

            return(Ok());
        }
Exemple #9
0
 public OperationResult RegisterParticipant(NewParticipant model)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         var participant = new Participants
         {
             Id = Guid.NewGuid(),
             RegDate = DateTime.Now,
             Email = model.Email.Trim(),
             Name = model.Name.Trim(),
             EthAddress = model.EthAddress,
             Avatar = model.Avatar
         };
         context.Add(participant);
         context.SaveChanges();
     }));
 }
Exemple #10
0
        public OperationResult CheckNewParticipant(NewParticipant model)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var tournament = context.Tournaments.FirstOrDefault();
                if (tournament == null || !tournament.IsEnabled || (tournament.RegisterDateTo.HasValue && tournament.RegisterDateTo < DateTime.Now))
                {
                    throw new Exception("Registration is closed");
                }

                var exist = context.Participants.Any(x => x.Email.ToLower() == model.Email.ToLower().Trim());
                if (exist)
                {
                    throw new Exception("Email already registered");
                }
            }));
        }
Exemple #11
0
        public Event AddParticipantToEvent([FromBody] NewParticipant newParticipant)
        {
            Event eventToEdit = dataContext.Events
                                .Include(x => x.Participants)
                                .Where(x => x.Id == newParticipant.EventId)
                                .FirstOrDefault();

            if (eventToEdit.Participants.Any(x => x.UserId == newParticipant.Participant.UserId))
            {
                return(null);
            }

            eventToEdit.Participants.Add(newParticipant.Participant);
            dataContext.Update(eventToEdit);
            dataContext.SaveChanges();

            return(eventToEdit);
        }
        public async Task Should_add_participants_to_video_hearing()
        {
            var seededHearing = await Hooks.SeedVideoHearing();

            TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}");
            _newHearingId = seededHearing.Id;

            var beforeCount = seededHearing.GetParticipants().Count;

            const string caseTypeName = "Generic";
            var          caseType     = GetCaseTypeFromDb(caseTypeName);

            var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant");
            var applicantRepresentativeHearingRole =
                applicantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var newPerson      = new PersonBuilder(true).Build();
            var newParticipant = new NewParticipant()
            {
                Person      = newPerson,
                CaseRole    = applicantCaseRole,
                HearingRole = applicantRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Representee = string.Empty
            };
            var participants = new List <NewParticipant>()
            {
                newParticipant
            };

            await _commandHandler.Handle(new AddParticipantsToVideoHearingCommand(_newHearingId, participants, null));

            var returnedVideoHearing =
                await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id));

            var afterCount = returnedVideoHearing.GetParticipants().Count;

            afterCount.Should().BeGreaterThan(beforeCount);
        }
Exemple #13
0
        private void AddParticipant(List <ProjectParticipant> participants, IList <UserProfile> correspondingProfiles,
                                    NewParticipant newParticipant, bool isInitiator)
        {
            var correspondingUserProfile =
                correspondingProfiles.FirstOrDefault(x => x.ApplicationUser.Email == newParticipant.NameOrEmail);

            if (correspondingUserProfile != null && correspondingUserProfile.Employments.Count == 0)
            {
                correspondingUserProfile.Employments.Add(new Employment {
                    Position = newParticipant.JobPosition
                });
            }

            if (correspondingUserProfile == null)
            {
                correspondingUserProfile = new UserProfile
                {
                    FirstName       = newParticipant.NameOrEmail,
                    ApplicationUser = new ApplicationUser {
                        UserName = newParticipant.NameOrEmail
                    },
                    Employments = new List <Employment> {
                        new Employment {
                            Position = newParticipant.JobPosition
                        }
                    }
                };
            }

            participants.Add(new ProjectParticipant
            {
                NameOrEmail = newParticipant.NameOrEmail,
                UserProfile = correspondingUserProfile,
                IsInitiator = isInitiator
            });
        }
Exemple #14
0
        public async Task Should_be_able_to_save_video_hearing_to_database()
        {
            var caseTypeName    = "Generic";
            var caseType        = GetCaseTypeFromDb(caseTypeName);
            var hearingTypeName = "Automated Test";
            var hearingType     = caseType.HearingTypes.First(x => x.Name == hearingTypeName);
            var scheduledDate   = DateTime.Today.AddHours(10).AddMinutes(30);
            var duration        = 45;
            var venue           = new RefDataBuilder().HearingVenues.First();

            var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant");
            var applicantRepresentativeHearingRole =
                applicantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var judgeCaseRole    = caseType.CaseRoles.First(x => x.Name == "Judge");
            var judgeHearingRole = judgeCaseRole.HearingRoles.First(x => x.Name == "Judge");

            var newPerson      = new PersonBuilder(true).Build();
            var newJudgePerson = new PersonBuilder(true).Build();
            var newParticipant = new NewParticipant()
            {
                Person      = newPerson,
                CaseRole    = applicantCaseRole,
                HearingRole = applicantRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Representee = string.Empty
            };
            var newJudgeParticipant = new NewParticipant()
            {
                Person      = newJudgePerson,
                CaseRole    = judgeCaseRole,
                HearingRole = judgeHearingRole,
                DisplayName = $"{newJudgePerson.FirstName} {newJudgePerson.LastName}",
                Representee = string.Empty
            };
            var participants = new List <NewParticipant>()
            {
                newParticipant, newJudgeParticipant
            };
            var cases = new List <Case> {
                new Case("01234567890", "Test Add")
            };
            var        hearingRoomName          = "Room01";
            var        otherInformation         = "OtherInformation01";
            var        createdBy                = "User01";
            const bool questionnaireNotRequired = false;
            const bool audioRecordingRequired   = true;

            var endpoints = new List <NewEndpoint>
            {
                new NewEndpoint
                {
                    DisplayName             = "display 1",
                    Sip                     = Guid.NewGuid().ToString(),
                    Pin                     = "1234",
                    DefenceAdvocateUsername = null
                },
                new NewEndpoint
                {
                    DisplayName             = "display 2",
                    Sip                     = Guid.NewGuid().ToString(),
                    Pin                     = "5678",
                    DefenceAdvocateUsername = null
                }
            };

            var linkedParticipants = new List <LinkedParticipantDto>
            {
                new LinkedParticipantDto(
                    newParticipant.Person.ContactEmail,
                    newJudgeParticipant.Person.ContactEmail,
                    LinkedParticipantType.Interpreter)
            };

            var command =
                new CreateVideoHearingCommand(caseType, hearingType, scheduledDate, duration, venue,
                                              participants, cases, questionnaireNotRequired, audioRecordingRequired, endpoints,
                                              linkedParticipants)
            {
                HearingRoomName  = hearingRoomName,
                OtherInformation = otherInformation,
                CreatedBy        = createdBy
            };
            await _commandHandler.Handle(command);

            command.NewHearingId.Should().NotBeEmpty();
            _newHearingId = command.NewHearingId;
            Hooks.AddHearingForCleanup(_newHearingId);
            var returnedVideoHearing = await _queryHandler.Handle(new GetHearingByIdQuery(_newHearingId));

            returnedVideoHearing.Should().NotBeNull();

            returnedVideoHearing.CaseType.Should().NotBeNull();
            returnedVideoHearing.HearingVenue.Should().NotBeNull();
            returnedVideoHearing.HearingType.Should().NotBeNull();

            var participantsFromDb = returnedVideoHearing.GetParticipants();

            participantsFromDb.Any().Should().BeTrue();
            returnedVideoHearing.GetCases().Any().Should().BeTrue();
            returnedVideoHearing.GetEndpoints().Any().Should().BeTrue();
            var linkedParticipantsFromDb = participantsFromDb.SelectMany(x => x.LinkedParticipants).ToList();

            linkedParticipantsFromDb.Should().NotBeEmpty();
            foreach (var linkedParticipant in linkedParticipantsFromDb)
            {
                linkedParticipant.Type.Should().BeAssignableTo <LinkedParticipantType>();
                linkedParticipant.Type.Should().Be(LinkedParticipantType.Interpreter);
                participantsFromDb.Any(x => x.Id == linkedParticipant.LinkedId).Should().BeTrue();
                participantsFromDb.Any(x => x.Id == linkedParticipant.ParticipantId).Should().BeTrue();
            }
        }
        public async Task Should_be_able_to_save_video_hearing_to_database()
        {
            var caseTypeName    = "Civil Money Claims";
            var caseType        = GetCaseTypeFromDb(caseTypeName);
            var hearingTypeName = "Application to Set Judgment Aside";
            var hearingType     = caseType.HearingTypes.First(x => x.Name == hearingTypeName);
            var scheduledDate   = DateTime.Today.AddHours(10).AddMinutes(30);
            var duration        = 45;
            var venue           = new RefDataBuilder().HearingVenues.First();

            var claimantCaseRole = caseType.CaseRoles.First(x => x.Name == "Claimant");
            var claimantRepresentativeHearingRole = claimantCaseRole.HearingRoles.First(x => x.Name == "Representative");

            var judgeCaseRole    = caseType.CaseRoles.First(x => x.Name == "Judge");
            var judgeHearingRole = judgeCaseRole.HearingRoles.First(x => x.Name == "Judge");

            var newPerson      = new PersonBuilder(true).Build();
            var newJudgePerson = new PersonBuilder(true).Build();
            var newParticipant = new NewParticipant()
            {
                Person      = newPerson,
                CaseRole    = claimantCaseRole,
                HearingRole = claimantRepresentativeHearingRole,
                DisplayName = $"{newPerson.FirstName} {newPerson.LastName}",
                Reference   = string.Empty,
                Representee = string.Empty
            };
            var newJudgeParticipant = new NewParticipant()
            {
                Person      = newJudgePerson,
                CaseRole    = judgeCaseRole,
                HearingRole = judgeHearingRole,
                DisplayName = $"{newJudgePerson.FirstName} {newJudgePerson.LastName}",
                Reference   = string.Empty,
                Representee = string.Empty
            };
            var participants = new List <NewParticipant>()
            {
                newParticipant, newJudgeParticipant
            };
            var cases = new List <Case> {
                new Case("01234567890", "Test Add")
            };
            var        hearingRoomName          = "Room01";
            var        otherInformation         = "OtherInformation01";
            var        createdBy                = "User01";
            const bool questionnaireNotRequired = false;
            const bool audioRecordingRequired   = true;

            var command =
                new CreateVideoHearingCommand(caseType, hearingType, scheduledDate, duration, venue,
                                              participants, cases, questionnaireNotRequired, audioRecordingRequired)
            {
                HearingRoomName  = hearingRoomName,
                OtherInformation = otherInformation,
                CreatedBy        = createdBy
            };
            await _commandHandler.Handle(command);

            command.NewHearingId.Should().NotBeEmpty();
            _newHearingId = command.NewHearingId;

            var returnedVideoHearing = await _queryHandler.Handle(new GetHearingByIdQuery(_newHearingId));

            returnedVideoHearing.Should().NotBeNull();

            returnedVideoHearing.CaseType.Should().NotBeNull();
            returnedVideoHearing.HearingVenue.Should().NotBeNull();
            returnedVideoHearing.HearingType.Should().NotBeNull();

            returnedVideoHearing.GetParticipants().Any().Should().BeTrue();
            returnedVideoHearing.GetCases().Any().Should().BeTrue();
        }
Exemple #16
0
 public void NewParticipant(NewParticipant obj)
 {
     Participants.Add(obj.Participant);
 }