protected Participant(Person person, HearingRole hearingRole, CaseRole caseRole) : this() { Person = person; PersonId = person.Id; HearingRoleId = hearingRole.Id; CaseRoleId = caseRole.Id; }
public async Task Should_succesfully_return_HearingRoleResponses() { var caseTypeName = "test"; var caseRoleName = "TestRole"; var caseRole = new CaseRole(1, "TestRole") { HearingRoles = new List <HearingRole> { new HearingRole(1, "HearingRoleTest") } }; var caseType = new CaseType(1, "Civil") { CaseRoles = new List <CaseRole> { caseRole } }; QueryHandler.Setup(q => q.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>())).ReturnsAsync(caseType); var result = await Controller.GetHearingRolesForCaseRole(caseTypeName, caseRoleName); result.Should().NotBeNull(); var objectResult = (ObjectResult)result; objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var response = (List <HearingRoleResponse>)objectResult.Value; response.Count.Should().Be(1); response[0].Name.Should().Be("HearingRoleTest"); }
public void Should_map_representative() { var caseRole = new CaseRole(1, "Claimant"); var hearingRole = new HearingRole(2, "Representative") { UserRole = new UserRole(6, "Representative") }; var person = new PersonBuilder().WithOrganisation().Build(); var representative = new Representative(person, hearingRole, caseRole) { Reference = "HUHIUHFIH", Representee = "Mr A. Daijif", DisplayName = "I. Vidual", CreatedBy = "*****@*****.**" }; representative.SetProtected(nameof(representative.CaseRole), caseRole); representative.SetProtected(nameof(representative.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(representative); AssertParticipantCommonDetails(response, representative, caseRole, hearingRole); AssertRepresentativeResponse(response, representative); AssertAddressMapping(response, null); response.Organisation.Should().Be(person.Organisation.Name); }
public void Should_map_individual() { var caseRole = new CaseRole(1, "Claimant"); var hearingRole = new HearingRole(1, "Claimant LIP") { UserRole = new UserRole(5, "Individual") }; var person = new PersonBuilder().WithAddress().WithOrganisation().Build(); var individual = new Individual(person, hearingRole, caseRole) { DisplayName = "I. Vidual", CreatedBy = "*****@*****.**" }; individual.SetProtected(nameof(individual.CaseRole), caseRole); individual.SetProtected(nameof(individual.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(individual); AssertParticipantCommonDetails(response, individual, caseRole, hearingRole); AssertRepresentativeResponse(response, null); AssertAddressMapping(response, person); response.Organisation.Should().Be(person.Organisation.Name); }
public void Should_map_judge() { var caseRole = new CaseRole(5, "Judge"); var hearingRole = new HearingRole(13, "Judge") { UserRole = new UserRole(4, "Judge") }; var person = new PersonBuilder().Build(); var judge = new Judge(person, hearingRole, caseRole) { DisplayName = "Judge", CreatedBy = "*****@*****.**" }; judge.SetProtected(nameof(judge.CaseRole), caseRole); judge.SetProtected(nameof(judge.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(judge); AssertParticipantCommonDetails(response, judge, caseRole, hearingRole); AssertRepresentativeResponse(response, null); AssertAddressMapping(response, null); response.Organisation.Should().BeNullOrWhiteSpace(); }
public void Should_Map_Individual_With_Linked_Participants() { var caseRole = new CaseRole(1, "Applicant"); var hearingRole = new HearingRole(1, "Litigant in person") { UserRole = new UserRole(5, "Individual") }; var person = new PersonBuilder().Build(); var linkedId = Guid.NewGuid(); var link = new List <LinkedParticipant> { new LinkedParticipant(Guid.NewGuid(), linkedId, LinkedParticipantType.Interpreter) }; var individual = new Individual(person, hearingRole, caseRole) { DisplayName = "Individual guy", CreatedBy = "*****@*****.**", LinkedParticipants = link }; individual.SetProtected(nameof(individual.CaseRole), caseRole); individual.SetProtected(nameof(individual.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(individual); AssertParticipantCommonDetails(response, individual, caseRole, hearingRole); AssertRepresentativeResponse(response, null); response.LinkedParticipants.Should().NotContainNulls(); response.LinkedParticipants.Select(x => x.LinkedId).Should().BeEquivalentTo(linkedId); }
public void Should_map_staffMember() { const string staffMemberName = "Staff Member"; var caseRole = new CaseRole(222, staffMemberName); var staffMemberUserId = UserRoleForHearingRole.UserRoleId["Staff Member"]; var hearingRole = new HearingRole(727, staffMemberName) { UserRole = new UserRole(staffMemberUserId, staffMemberName) }; var person = new PersonBuilder().Build(); var staffMember = new StaffMember(person, hearingRole, caseRole) { DisplayName = "Staff Member", CreatedBy = "*****@*****.**" }; staffMember.SetProtected(nameof(staffMember.CaseRole), caseRole); staffMember.SetProtected(nameof(staffMember.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(staffMember); AssertParticipantCommonDetails(response, staffMember, caseRole, hearingRole); AssertRepresentativeResponse(response, null); response.Organisation.Should().BeNullOrWhiteSpace(); }
public ActionResult DeleteConfirmed(int id) { CaseRole caseRole = db.CaseRoles.Find(id); db.CaseRoles.Remove(caseRole); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnOk_Click(object sender, EventArgs e) { this.NounIndex = this.cmbNounFrames.SelectedIndex; this.VerbIndex = this.cmbVerbFrames.SelectedIndex; this.Relation = (CaseRole)this.cmbCaseRoles.SelectedIndex; this.DialogResult = DialogResult.OK; this.Close(); }
public ActionResult Edit([Bind(Include = "Id,Title,Type")] CaseRole caseRole) { if (ModelState.IsValid) { db.Entry(caseRole).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(caseRole)); }
public void Should_map_all_properties() { var refDataBuilder = new RefDataBuilder(); var venue = refDataBuilder.HearingVenues.First(x => x.Name == _hearingVenueName); var caseType = new CaseType(1, _caseTypeName); var hearingType = Builder <HearingType> .CreateNew().WithFactory(() => new HearingType(_hearingTypeName)).Build(); var scheduledDateTime = DateTime.Today.AddDays(1).AddHours(11).AddMinutes(45); var duration = 80; var hearingRoomName = "Roome03"; var otherInformation = "OtherInformation03"; var createdBy = "User03"; const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var hearing = new VideoHearing(caseType, hearingType, scheduledDateTime, duration, venue, hearingRoomName, otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason); _videoHearing = Builder <VideoHearing> .CreateNew().WithFactory(() => hearing).Build(); var applicantCaseRole = new CaseRole(1, "Applicant"); var applicantLipHearingRole = new HearingRole(1, "Litigant in person") { UserRole = new UserRole(1, "Individual") }; _videoHearing.AddCase("0875", "Test Case Add", false); var person1 = new PersonBuilder(true).Build(); _videoHearing.AddIndividual(person1, applicantLipHearingRole, applicantCaseRole, $"{person1.FirstName} {person1.LastName}"); var party = _videoHearing.GetParticipants().FirstOrDefault(); party.SetProtected(nameof(party.CaseRole), applicantCaseRole); party.SetProtected(nameof(party.HearingRole), applicantLipHearingRole); var endpoints = new Endpoint("displayName", "333", "200", null); _videoHearing.AddEndpoint(endpoints); // Set the navigation properties as well since these would've been set if we got the hearing from DB _videoHearing.SetProtected(nameof(_videoHearing.HearingType), hearingType); _videoHearing.SetProtected(nameof(_videoHearing.CaseType), caseType); _videoHearing.SetProtected(nameof(_videoHearing.HearingVenue), venue); var response = _mapper.MapHearingToDetailedResponse(_videoHearing); response.Should().BeEquivalentTo(response, options => options .Excluding(v => v.Id) ); }
public ActionResult Create([Bind(Include = "Id,Title,Type")] CaseRole caseRole) { if (ModelState.IsValid) { db.CaseRoles.Add(caseRole); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(caseRole)); }
//public Dictionary<CaseRole, List<VerbFrame>> Associatedactions //{ // get { return _associatedactions; } //} //public void AddCaseRole(CaseRole role,VerbFrame verbFrame) //{ // if (_associatedactions.ContainsKey(role)) // { // _associatedactions[role].Add(verbFrame); // } // else // { // List<VerbFrame> vframes = new List<VerbFrame>(); // vframes.Add(verbFrame); // _associatedactions.Add(role,vframes); // } //} public void AddCaseRolenouns(CaseRole role, NounFrame nounframe) { if (_ownerof.ContainsKey(role)) { _ownerof[role].Add(nounframe); } else { List <NounFrame> nframes = new List <NounFrame>(); nframes.Add(nounframe); _ownerof.Add(role, nframes); } }
public void AddCaseRole(CaseRole caseRole, NounFrame frame) { if (_caseRoles.ContainsKey(caseRole)) { _caseRoles[caseRole].Add(frame); } else { List <NounFrame> verbframelst = new List <NounFrame>(); verbframelst.Add(frame); _caseRoles.Add(caseRole, verbframelst); } }
public void AddCaseRole(CaseRole role, VerbFrame verbFrame) { if (_associatedactions.ContainsKey(role)) { _associatedactions[role].Add(verbFrame); } else { List <VerbFrame> vframes = new List <VerbFrame>(); vframes.Add(verbFrame); _associatedactions.Add(role, vframes); } }
public void Should_raise_exception_if_adding_judicial_office_holder_twice() { var hearingBuilder = new VideoHearingBuilder(); var hearing = hearingBuilder.Build(); var existingJoh = hearingBuilder.JudicialOfficeHolder; var johCaseRole = new CaseRole(7, "Judicial Office Holder"); var johHearingRole = new HearingRole(14, "Judicial Office Holder"); var newPerson = new PersonBuilder(existingJoh.Username).Build(); When(() => hearing.AddJudicialOfficeHolder(newPerson, johHearingRole, johCaseRole, "Joh")) .Should().Throw <DomainRuleException>().WithMessage("Judicial office holder already exists in the hearing"); }
public void Should_raise_exception_if_adding_judge_twice() { var hearingBuilder = new VideoHearingBuilder(); var hearing = hearingBuilder.Build(); var existingJudge = hearingBuilder.Judge; var judgeCaseRole = new CaseRole(5, "Judge"); var judgeHearingRole = new HearingRole(13, "Judge"); var newPerson = new PersonBuilder(existingJudge.Username).Build(); When(() => hearing.AddJudge(newPerson, judgeHearingRole, judgeCaseRole, "Judge Dredd")) .Should().Throw <DomainRuleException>().WithMessage("Judge with given username already exists in the hearing"); }
public void Should_add_judge_to_hearing() { var hearing = new VideoHearingBuilder().Build(); var judgeCaseRole = new CaseRole(5, "Judge"); var judgeHearingRole = new HearingRole(13, "Judge"); var newPerson = new PersonBuilder(true).Build(); var beforeAddCount = hearing.GetParticipants().Count; hearing.AddJudge(newPerson, judgeHearingRole, judgeCaseRole, "Judge Display Name"); var afterAddCount = hearing.GetParticipants().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
public void Should_add_judicial_office_holder_to_hearing() { var hearing = new VideoHearingBuilder().Build(); var johCaseRole = new CaseRole(7, "Judicial Office Holder"); var johHearingRole = new HearingRole(14, "Judicial Office Holder"); var newPerson = new PersonBuilder(true).Build(); var beforeAddCount = hearing.GetParticipants().Count; hearing.AddJudicialOfficeHolder(newPerson, johHearingRole, johCaseRole, "Joh Display Name"); var afterAddCount = hearing.GetParticipants().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CaseRole caseRole = db.CaseRoles.Find(id); if (caseRole == null) { return(HttpNotFound()); } return(View(caseRole)); }
public async Task Should_return_mapped_participants() { const string email = "*****@*****.**"; var caseRole = new CaseRole(1, ""); var hearingRole = new HearingRole(1, ""); var participants = new List <Participant> { new Individual ( new Person("mr", "test", "er", "*****@*****.**"), hearingRole, caseRole ), new Individual ( new Person("mr", "test", "er", "*****@*****.**"), hearingRole, caseRole ) }; participants[0].Person.Organisation = new Organisation(""); participants[0].CaseRole = caseRole; participants[0].CaseRole.HearingRoles = new List <HearingRole>(); participants[0].HearingRole = hearingRole; participants[0].HearingRole.UserRole = new UserRole(1, ""); participants[1].Person.Organisation = new Organisation(""); participants[1].CaseRole = caseRole; participants[1].CaseRole.HearingRoles = new List <HearingRole>(); participants[1].HearingRole = hearingRole; participants[1].HearingRole.UserRole = new UserRole(1, ""); _queryHandlerMock .Setup(x => x.Handle <GetParticipantsByUsernameQuery, List <Participant> >(It.IsAny <GetParticipantsByUsernameQuery>())) .ReturnsAsync(participants); var result = await _controller.GetParticipantsByUsername(email); result.Should().NotBeNull(); var objectResult = result as OkObjectResult; var data = (IEnumerable <ParticipantResponse>)objectResult.Value; data.Count().Should().Be(2); objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); }
public ParticipantBuilder() { var claimantCaseRole = new CaseRole(1, "Claimant"); var defendantCaseRole = new CaseRole(2, "Defendant"); var claimantLipHearingRole = new HearingRole(1, "Claimant LIP"); claimantLipHearingRole.UserRole = new UserRole(5, "Individual"); var defendantRepresentativeHearingRole = new HearingRole(5, "Representative"); defendantRepresentativeHearingRole.UserRole = new UserRole(6, "Representative"); var defendantLipHearingRole = new HearingRole(4, "Defendant LIP"); defendantLipHearingRole.UserRole = new UserRole(5, "Individual"); var person1 = new PersonBuilder(true).WithAddress().Build(); var person2 = new PersonBuilder(true).WithAddress().Build(); var person3 = new PersonBuilder(true).Build(); _individualParticipant1 = new Individual(person1, claimantLipHearingRole, claimantCaseRole); _individualParticipant1.HearingRole = claimantLipHearingRole; _individualParticipant1.Questionnaire = new Questionnaire { Participant = _individualParticipant1, ParticipantId = _individualParticipant1.Id }; _individualParticipant1.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _individualParticipant2 = new Individual(person2, defendantLipHearingRole, defendantCaseRole); _individualParticipant2.HearingRole = defendantLipHearingRole; _individualParticipant2.Questionnaire = new Questionnaire { Participant = _individualParticipant2, ParticipantId = _individualParticipant2.Id }; _individualParticipant2.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _representativeParticipant = new Representative(person3, defendantRepresentativeHearingRole, defendantCaseRole); _representativeParticipant.HearingRole = defendantRepresentativeHearingRole; _representativeParticipant.Questionnaire = new Questionnaire { Participant = _representativeParticipant, ParticipantId = _representativeParticipant.Id }; _representativeParticipant.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _participants.Add(_individualParticipant1); _participants.Add(_individualParticipant2); _participants.Add(_representativeParticipant); }
public ParticipantBuilder() { var applicantCaseRole = new CaseRole(1, "Applicant"); var respondentCaseRole = new CaseRole(2, "Respondent"); var applicantLipHearingRole = new HearingRole(1, "Litigant in person"); applicantLipHearingRole.UserRole = new UserRole(5, "Individual"); var respondentRepresentativeHearingRole = new HearingRole(5, "Representative"); respondentRepresentativeHearingRole.UserRole = new UserRole(6, "Representative"); var respondentLipHearingRole = new HearingRole(4, "Litigant in person"); respondentLipHearingRole.UserRole = new UserRole(5, "Individual"); var person1 = new PersonBuilder(true).Build(); var person2 = new PersonBuilder(true).Build(); var person3 = new PersonBuilder(true).Build(); _individualParticipant1 = new Individual(person1, applicantLipHearingRole, applicantCaseRole); _individualParticipant1.HearingRole = applicantLipHearingRole; _individualParticipant1.Questionnaire = new Questionnaire { Participant = _individualParticipant1, ParticipantId = _individualParticipant1.Id }; _individualParticipant1.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _individualParticipant2 = new Individual(person2, respondentLipHearingRole, respondentCaseRole); _individualParticipant2.HearingRole = respondentLipHearingRole; _individualParticipant2.Questionnaire = new Questionnaire { Participant = _individualParticipant2, ParticipantId = _individualParticipant2.Id }; _individualParticipant2.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _representativeParticipant = new Representative(person3, respondentRepresentativeHearingRole, respondentCaseRole); _representativeParticipant.HearingRole = respondentRepresentativeHearingRole; _representativeParticipant.Questionnaire = new Questionnaire { Participant = _representativeParticipant, ParticipantId = _representativeParticipant.Id }; _representativeParticipant.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); _participants.Add(_individualParticipant1); _participants.Add(_individualParticipant2); _participants.Add(_representativeParticipant); }
public void Should_add_new_participant_to_hearing() { var hearing = new VideoHearingBuilder().Build(); var claimantCaseRole = new CaseRole(1, "Claimant"); var claimantRepresentativeHearingRole = new HearingRole(2, "Representative"); var newPerson = new PersonBuilder(true).Build(); var beforeAddCount = hearing.GetParticipants().Count; hearing.AddRepresentative(newPerson, claimantRepresentativeHearingRole, claimantCaseRole, "Display Name", string.Empty, string.Empty); var afterAddCount = hearing.GetParticipants().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
private void btnAddCaseRole_Click(object sender, EventArgs e) { FrmCaseRoleRelation form = new FrmCaseRoleRelation(tmr.Nounframes, tmr.VerbFrames); if (form.ShowDialog() == DialogResult.OK) { NounFrame currentNoun = tmr.Nounframes[form.NounIndex]; CaseRole c = form.Relation; int currentVerbIndex = form.VerbIndex; if (!this.tmr.VerbFrames[currentVerbIndex].CaseRoles.ContainsKey(c) || !this.tmr.VerbFrames[currentVerbIndex].CaseRoles[c].Contains(currentNoun)) { this.tmr.VerbFrames[currentVerbIndex].AddCaseRole(c, currentNoun); this.viewer.UpdateRelations(); } } }
public void Should_not_remove_participant_that_does_not_exist_in_hearing() { var hearing = new VideoHearingBuilder().Build(); var applicantCaseRole = new CaseRole(1, "Applicant"); var applicantRepresentativeHearingRole = new HearingRole(2, "Representative"); var newPerson = new PersonBuilder(true).Build(); var participant = Builder <Representative> .CreateNew().WithFactory(() => new Representative(newPerson, applicantRepresentativeHearingRole, applicantCaseRole) ).Build(); Action action = () => hearing.RemoveParticipant(participant); action.Should().Throw <DomainRuleException>().And.ValidationFailures.Any(x => x.Name == "Participant" && x.Message == "Participant does not exist on the hearing").Should().BeTrue(); }
public Participant AddJudge(Person person, HearingRole hearingRole, CaseRole caseRole, string displayName) { if (DoesParticipantExist(person.Username)) { throw new DomainRuleException(nameof(person), "Judge with given username already exists in the hearing"); } Participant participant = new Judge(person, hearingRole, caseRole) { DisplayName = displayName, CreatedBy = CreatedBy }; Participants.Add(participant); UpdatedDate = DateTime.UtcNow; return(participant); }
public Participant AddRepresentative(Person person, HearingRole hearingRole, CaseRole caseRole, string displayName, string representee) { if (DoesParticipantExist(person.Username)) { throw new DomainRuleException(nameof(person), "Participant already exists in the hearing"); } Participant participant = new Representative(person, hearingRole, caseRole) { Representee = representee }; participant.DisplayName = displayName; participant.CreatedBy = CreatedBy; Participants.Add(participant); UpdatedDate = DateTime.UtcNow; return(participant); }
protected CaseRole CreateCaseAndHearingRoles(int caseId, string caseRoleName, string userRole, List <string> roles) { var hearingRoles = new List <HearingRole>(); foreach (var role in roles) { hearingRoles.Add(new HearingRole(1, role) { UserRole = new UserRole(1, userRole) }); } var caseRole = new CaseRole(caseId, caseRoleName) { HearingRoles = hearingRoles }; return(caseRole); }
private static void AssertParticipantCommonDetails(ParticipantResponse response, Participant participant, CaseRole caseRole, HearingRole hearingRole) { response.Id.Should().Be(participant.Id); response.DisplayName.Should().Be(participant.DisplayName); response.CaseRoleName.Should().Be(caseRole.Name); response.HearingRoleName.Should().Be(hearingRole.Name); response.UserRoleName.Should().Be(hearingRole.UserRole.Name); var person = participant.Person; response.Title.Should().Be(person.Title); response.FirstName.Should().Be(person.FirstName); response.MiddleNames.Should().Be(person.MiddleNames); response.LastName.Should().Be(person.LastName); response.ContactEmail.Should().Be(person.ContactEmail); response.TelephoneNumber.Should().Be(person.TelephoneNumber); response.Username.Should().Be(person.Username); }