예제 #1
0
        public OtherEventReport Create(OtherEventReport report)
        {
            report.Id = _otherEventReportCommandService.CreateReportWithTemplate(
                report.TemplateId,
                report.IsSupplement,
                report);

            return(report);
        }
예제 #2
0
 public void ClassSetUp()
 {
     _factory        = new MockRepository(MockBehavior.Loose);
     _identityId     = Guid.NewGuid();
     identityContext = new IdentityContext()
     {
         IdentityId = Guid.NewGuid()
     };
     _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
     _identityProvider    = new Mock <IServiceIdentityProvider>();
     _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId);
     _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext);
     _otherEventReport = new OtherEventReport(DataEntryUnitTestFixture.IdentityId, DataEntryUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), false);
 }
예제 #3
0
        public void ClassSetUp()
        {
            _factory           = new MockRepository(MockBehavior.Loose);
            _reportsUnitOfWork = _factory.Create <IReportsUnitOfWork>();
            var dependencyContainer = _factory.Create <IDependencyContainer>();
            var agencyQueryService  = _factory.Create <IAgencyQueryService>();

            dependencyContainer.Setup(mock => mock.Resolve <IAgencyQueryService>()).Returns(agencyQueryService.Object);
            DependencyContainer.SetInstance(dependencyContainer.Object);
            _otherEventReport = new OtherEventReport(DataEntryUnitTestFixture.IdentityId, DataEntryUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), false);
            var reportList = new List <Report>();

            reportList.Add(_otherEventReport);
            _reportsUnitOfWork.Setup(mock => mock.GetEntityQuery <Report>(It.IsAny <TrackingMode>())).Returns(reportList.AsQueryable());
            _reportsUnitOfWork.Setup(mock => mock.Find <OtherEventReport>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>())).Returns(_otherEventReport);
            _otherEventReportQueryService = new OtherEventReportQueryService(_reportsUnitOfWork.Object, Mock.Of <ILog>(), Mock.Of <IServiceAuthorizationPolicy>(), Mock.Of <IServiceIdentityProvider>());
        }
예제 #4
0
        private void PrepareOtherEventReportSectionsForReport(Section templateSection, string sectionHeader,
                                                              OtherEventReport otherEventReport, IReportsData reportDetails)
        {
            //All Public Safety type items
            var itemList = new List <IPublicSafetyEntityDetails>();

            switch (templateSection.SectionType)
            {
            case SectionType.Event:
                itemList.Add(otherEventReport.Event);
                sectionHeader = GenericSectionName.EVENT;
                PreparePublicSafetyEntityForReport(templateSection, itemList, sectionHeader, string.Empty, reportDetails);
                break;

            case SectionType.Offense:
                sectionHeader = GenericSectionName.OFFENSES;
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Offenses.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;

            case SectionType.Person:
                if (templateSection.Name == GenericSectionName.OTHERS)
                {
                    #region victims from others section
                    var otherVictims =
                        otherEventReport.People.FindAll(
                            x =>
                            String.Equals(x.InvolvementType.Code, GenericSectionName.VICTIM,
                                          StringComparison.CurrentCultureIgnoreCase));

                    if (otherVictims.Count > 0)
                    {
                        PreparePublicSafetyEntityForReport(templateSection,
                                                           otherVictims.ToList <IPublicSafetyEntityDetails>(), GenericSectionName.VICTIMS,
                                                           string.Empty, reportDetails,
                                                           string.Empty, _runningIndexVictim);

                        _runningIndexVictim = (_runningIndexVictim > 0 ? _runningIndexVictim : 0) +
                                              otherVictims.Count;
                    }
                    #endregion

                    #region suspects from others section

                    var otherSuspects =
                        otherEventReport.People.FindAll(
                            x =>
                            String.Equals(x.InvolvementType.Code, GenericSectionName.SUSPECT,
                                          StringComparison.CurrentCultureIgnoreCase));

                    if (otherSuspects.Count > 0)
                    {
                        PreparePublicSafetyEntityForReport(templateSection,
                                                           otherSuspects.ToList <IPublicSafetyEntityDetails>(), GenericSectionName.SUSPECTS,
                                                           string.Empty, reportDetails,
                                                           string.Empty, _runningIndexSuspect);

                        _runningIndexSuspect = (_runningIndexSuspect > 0 ? _runningIndexSuspect : 0) +
                                               otherSuspects.Count;
                    }

                    #endregion

                    var otherInvolvementTypes =
                        otherEventReport.People.FindAll(
                            x =>
                            !String.Equals(x.InvolvementType.Code, GenericSectionName.VICTIM,
                                           StringComparison.CurrentCultureIgnoreCase) &&
                            !String.Equals(x.InvolvementType.Code, GenericSectionName.SUSPECT,
                                           StringComparison.CurrentCultureIgnoreCase));

                    if (otherInvolvementTypes.Count > 0)
                    {
                        PrepareOtherEventPersonEntityForReport(templateSection, otherInvolvementTypes,
                                                               sectionHeader, reportDetails);
                    }
                }
                break;

            case SectionType.Organization:
                #region victims from organization section
                var organizationVictims =
                    otherEventReport.Organizations.FindAll(x => String.Equals(x.InvolvementType.Code, GenericSectionName.VICTIM, StringComparison.CurrentCultureIgnoreCase));

                if (organizationVictims.Count > 0)
                {
                    PreparePublicSafetyEntityForReport(templateSection,
                                                       organizationVictims.ToList <IPublicSafetyEntityDetails>(), GenericSectionName.VICTIMS, string.Empty,
                                                       reportDetails,
                                                       string.Empty, _runningIndexVictim);

                    _runningIndexVictim = (_runningIndexVictim > 0 ? _runningIndexVictim : 0) + organizationVictims.Count;
                }
                #endregion

                #region suspects from organization section
                var organizationSuspects =
                    otherEventReport.Organizations.FindAll(x => String.Equals(x.InvolvementType.Code, GenericSectionName.SUSPECT, StringComparison.CurrentCultureIgnoreCase));

                if (organizationSuspects.Count > 0)
                {
                    PreparePublicSafetyEntityForReport(templateSection,
                                                       organizationSuspects.ToList <IPublicSafetyEntityDetails>(), GenericSectionName.SUSPECTS, string.Empty,
                                                       reportDetails,
                                                       string.Empty, _runningIndexSuspect);
                    _runningIndexSuspect = (_runningIndexSuspect > 0 ? _runningIndexSuspect : 0) + organizationSuspects.Count;
                }
                #endregion

                var organizationOthers =
                    otherEventReport.Organizations.FindAll(x => !String.Equals(x.InvolvementType.Code, GenericSectionName.VICTIM, StringComparison.CurrentCultureIgnoreCase) &&
                                                           !String.Equals(x.InvolvementType.Code, GenericSectionName.SUSPECT, StringComparison.CurrentCultureIgnoreCase));

                if (organizationOthers.Count > 0)
                {
                    PrepareOtherEventOrganizationOthersEntityForReport(templateSection, organizationOthers,
                                                                       GenericSectionName.OTHERS, reportDetails);
                }

                break;

            case SectionType.Vehicle:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Vehicles.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;

            case SectionType.Officer:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Officers.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;

            case SectionType.Narrative:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Narratives.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader,
                                                   string.Empty, reportDetails);
                break;

            case SectionType.Drug:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Drugs.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;

            case SectionType.Gun:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Guns.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;

            case SectionType.Property:
                PreparePublicSafetyEntityForReport(templateSection,
                                                   otherEventReport.Property.Cast <IPublicSafetyEntityDetails>().ToList(), sectionHeader, string.Empty,
                                                   reportDetails);
                break;
            }
        }