示例#1
0
        public async Task <SSG_SafetyConcernDetail> CreateSafetyConcern(SafetyConcernEntity safety, CancellationToken cancellationToken)
        {
            if (safety.Person.IsDuplicated)
            {
                Guid duplicatedSafetyId = await _duplicateDetectService.Exists(safety.Person, safety);

                if (duplicatedSafetyId != Guid.Empty)
                {
                    return new SSG_SafetyConcernDetail()
                           {
                               SafetyConcernDetailId = duplicatedSafetyId
                           }
                }
                ;
            }
            return(await this._oDataClient.For <SSG_SafetyConcernDetail>().Set(safety).InsertEntryAsync(cancellationToken));
        }
示例#2
0
        public async Task with_safetyconcern_entity_CreateSafetyConcern_should_return_new_SSG_SafetyConcern()
        {
            _odataClientMock.Setup(x => x.For <SSG_SafetyConcernDetail>(null).Set(It.Is <SafetyConcernEntity>(x => x.Detail == "safe"))
                                   .InsertEntryAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_SafetyConcernDetail()
            {
                SafetyConcernDetailId = _testAliasId
            })
                     );
            var safe = new SafetyConcernEntity()
            {
                Detail = "safe",
                Person = new SSG_Person()
                {
                }
            };
            var result = await _sut.CreateSafetyConcern(safe, CancellationToken.None);

            Assert.AreEqual(_testAliasId, result.SafetyConcernDetailId);
        }
示例#3
0
        private async Task <bool> UpdateSafetyConcern()
        {
            SSG_SafetyConcernDetail originalSafeEntity = _uploadedPerson.SSG_SafetyConcernDetails?.FirstOrDefault(m => m.IsCreatedByAgency);

            if (originalSafeEntity == null)
            {
                await UploadSafetyConcern(true);
            }
            else
            {
                SafetyConcernEntity         newSafeEntity = _mapper.Map <SafetyConcernEntity>(_personSought);
                Dictionary <string, object> updatedFields = (Dictionary <string, object>)originalSafeEntity.Clone().GetUpdateEntries(newSafeEntity);
                if (updatedFields.Count > 0)
                {
                    await _searchRequestService.UpdateSafetyConcern(originalSafeEntity.SafetyConcernDetailId, updatedFields, _cancellationToken);

                    _logger.LogInformation("Update Person successfully");
                }
            }

            return(true);
        }
示例#4
0
        private async Task <bool> UploadSafetyConcern(bool inUpdateProcess = false)
        {
            if (string.IsNullOrEmpty(_personSought.CautionFlag) &&
                string.IsNullOrEmpty(_personSought.CautionReason) &&
                string.IsNullOrEmpty(_personSought.CautionNotes))
            {
                return(true);
            }
            SafetyConcernEntity entity = _mapper.Map <SafetyConcernEntity>(_personSought);

            entity.SearchRequest     = _uploadedSearchRequest;
            entity.InformationSource = InformationSourceType.Request.Value;
            entity.Person            = _uploadedPerson;
            entity.IsCreatedByAgency = true;
            if (inUpdateProcess)
            {
                entity.UpdateDetails = "New Safety Concern";
            }
            await _searchRequestService.CreateSafetyConcern(entity, _cancellationToken);

            _logger.LogInformation("Create Safety Concern records for SearchRequest successfully");
            return(true);
        }
示例#5
0
        private async Task <bool> UploadSafetyConcern()
        {
            if (string.IsNullOrEmpty(_foundPerson.CautionFlag))
            {
                return(false);
            }
            try
            {
                SafetyConcernEntity entity = _mapper.Map <SafetyConcernEntity>(_foundPerson);
                entity.SearchRequest     = _searchRequest;
                entity.InformationSource = _providerDynamicsID;
                entity.Person            = _returnedPerson;
                SSG_SafetyConcernDetail safetyConcern = await _searchRequestService.CreateSafetyConcern(entity, _cancellationToken);
                await CreateResultTransaction(safetyConcern);

                _logger.LogInformation("Create Safety Concern records for SearchRequest successfully");
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex);
                return(false);
            }
        }
        public void Init()
        {
            _validRequestId           = Guid.NewGuid();
            _loggerMock               = new Mock <ILogger <AgencyRequestService> >();
            _searchRequestServiceMock = new Mock <ISearchRequestService>();
            _mapper = new Mock <IMapper>();

            _searchRequestPerson = new Person()
            {
                DateOfBirth   = DateTime.Now,
                FirstName     = "TEST1",
                LastName      = "TEST2",
                CautionFlag   = "cautionFlag",
                CautionReason = "violence",
                Identifiers   = new List <PersonalIdentifier>()
                {
                    new PersonalIdentifier()
                    {
                        Value = "test",
                        Type  = PersonalIdentifierType.BCDriverLicense,
                        Owner = OwnerType.PersonSought
                    },
                    new PersonalIdentifier()
                    {
                        Value = "test2",
                        Type  = PersonalIdentifierType.SocialInsuranceNumber,
                        Owner = OwnerType.PersonSought
                    }
                },
                Addresses = new List <Address>()
                {
                    new Address()
                    {
                        AddressLine1 = "AddressLine1",
                        AddressLine2 = "AddressLine2",
                        City         = "testCity",
                        Owner        = OwnerType.PersonSought
                    }
                },
                Phones = new List <Phone>()
                {
                    new Phone()
                    {
                        PhoneNumber = "4005678900"
                    }
                },
                Names = new List <Name>()
                {
                    new Name()
                    {
                        FirstName   = "firstName",
                        Owner       = OwnerType.PersonSought,
                        Identifiers = new List <PersonalIdentifier> {
                            new PersonalIdentifier {
                                Value = "123222", Type = PersonalIdentifierType.BCDriverLicense
                            }
                        },
                        Addresses = new List <Address> {
                            new Address {
                                AddressLine1 = "line1"
                            }
                        },
                        Phones = new List <Phone>
                        {
                            new Phone {
                                PhoneNumber = "12343"
                            }
                        }
                    },
                    new Name()
                    {
                        FirstName = "applicantFirstName",
                        Owner     = OwnerType.Applicant
                    }
                },
                RelatedPersons = new List <RelatedPerson>()
                {
                    new RelatedPerson()
                    {
                        FirstName = "firstName"
                    }
                },

                Employments = new List <Employment>()
                {
                    new Employment()
                    {
                        Occupation = "Occupation",
                        Employer   = new Employer()
                        {
                            Phones = new List <Phone>()
                            {
                                new Phone()
                                {
                                    PhoneNumber = "1111111", Type = "Phone"
                                }
                            }
                        }
                    }
                },
                Agency = new Agency {
                    Code = "FMEP"
                }
            };

            _searchRequstOrdered = new SearchRequestOrdered()
            {
                Action           = RequestAction.NEW,
                RequestId        = "1111111",
                SearchRequestId  = Guid.NewGuid(),
                TimeStamp        = new DateTime(2010, 1, 1),
                SearchRequestKey = "key",
                Person           = _searchRequestPerson
            };


            _fakePersoneIdentifier = new IdentifierEntity
            {
                Identification = "1234567",
                SearchRequest  = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                }
            };
            _fakePersonAddress = new AddressEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                },
                AddressLine1 = "addressLine1"
            };
            _fakeEmployment = new EmploymentEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                }
            };

            _fakeEmploymentContact = new EmploymentContactEntity
            {
                PhoneNumber = "11111111"
            };

            _fakePersonPhoneNumber = new PhoneNumberEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                }
            };

            _fakeRelatedPerson = new RelatedPersonEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                }
            };

            _fakeName = new AliasEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = _validRequestId
                }
            };

            _fakeSearchRequest = new SearchRequestEntity()
            {
                AgencyCode              = "FMEP",
                RequestPriority         = RequestPriorityType.Rush.Value,
                ApplicantAddressLine1   = "new Address line 1",
                ApplicantAddressLine2   = "",
                PersonSoughtDateOfBirth = new DateTime(1998, 1, 1),
                LocationRequested       = true,
                PHNRequested            = true,
                DateOfDeathRequested    = false
            };

            _fakeSafety = new SafetyConcernEntity {
                Detail = "safety"
            };

            _ssg_fakePerson = new PersonEntity
            {
            };

            _mapper.Setup(m => m.Map <IdentifierEntity>(It.IsAny <PersonalIdentifier>()))
            .Returns(_fakePersoneIdentifier);

            _mapper.Setup(m => m.Map <PhoneNumberEntity>(It.IsAny <Phone>()))
            .Returns(_fakePersonPhoneNumber);

            _mapper.Setup(m => m.Map <AddressEntity>(It.IsAny <Address>()))
            .Returns(_fakePersonAddress);

            _mapper.Setup(m => m.Map <AliasEntity>(It.IsAny <Name>()))
            .Returns(_fakeName);

            _mapper.Setup(m => m.Map <PersonEntity>(It.IsAny <Person>()))
            .Returns(_ssg_fakePerson);

            _mapper.Setup(m => m.Map <EmploymentEntity>(It.IsAny <Employment>()))
            .Returns(_fakeEmployment);

            _mapper.Setup(m => m.Map <EmploymentContactEntity>(It.IsAny <Phone>()))
            .Returns(_fakeEmploymentContact);

            _mapper.Setup(m => m.Map <RelatedPersonEntity>(It.IsAny <RelatedPerson>()))
            .Returns(_fakeRelatedPerson);

            _mapper.Setup(m => m.Map <SearchRequestEntity>(It.IsAny <SearchRequestOrdered>()))
            .Returns(_fakeSearchRequest);

            _mapper.Setup(m => m.Map <SafetyConcernEntity>(It.IsAny <Person>()))
            .Returns(_fakeSafety);

            _searchRequestServiceMock.Setup(x => x.CreateSearchRequest(It.Is <SearchRequestEntity>(x => x.AgencyCode == "FMEP"), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SearchRequest>(new SSG_SearchRequest()
            {
                SearchRequestId = _validRequestId,
                AgencyCode      = "SUCCEED"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.IsAny <IdentifierEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Identifier>(new SSG_Identifier()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateAddress(It.Is <AddressEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Address>(new SSG_Address()
            {
                AddressLine1 = "test full line"
            }));

            _searchRequestServiceMock.Setup(x => x.CreatePhoneNumber(It.Is <PhoneNumberEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_PhoneNumber>(new SSG_PhoneNumber()
            {
                TelePhoneNumber = "4007678231"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateName(It.Is <AliasEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Aliase>(new SSG_Aliase()
            {
                FirstName = "firstName"
            }));

            _searchRequestServiceMock.Setup(x => x.SavePerson(It.Is <PersonEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Person>(new SSG_Person()
            {
                FirstName = "First"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmployment(It.Is <EmploymentEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Employment>(new SSG_Employment()
            {
                EmploymentId = Guid.NewGuid(),
                Occupation   = "Occupation"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmploymentContact(It.IsAny <EmploymentContactEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_EmploymentContact>(new SSG_EmploymentContact()
            {
                PhoneNumber = "4007678231"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateRelatedPerson(It.Is <RelatedPersonEntity>(x => x.SearchRequest.SearchRequestId == _validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Identity>(new SSG_Identity()
            {
                FirstName = "firstName"
            }));

            _searchRequestServiceMock.Setup(x => x.SubmitToQueue(It.IsAny <Guid>()))
            .Returns(Task.FromResult <bool>(true));
            _sut = new AgencyRequestService(_searchRequestServiceMock.Object, _loggerMock.Object, _mapper.Object);
        }