public List <AttachmentRelationship> GetRelatedToAttachments(string number, Guid agencyId, ModuleType module, bool isSummary) { List <AttachmentRelationship> relatedToList = new List <AttachmentRelationship>(); IQueryable <IPublicSafetyAggregate> aggregateQuery; if (isSummary) { // Get the Summaries with the given number. aggregateQuery = _summaryContext.GetEntityQuery <Summary>() .Where(SummarySpecifications.ByNumber(agencyId, module, number)); } else { // Get the Reports with the given number. aggregateQuery = _reportContext.GetEntityQuery <Report>() .Where(ReportSpecifications.ByNumber(agencyId, module, number)); } relatedToList.AddRange(GetPersonsRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetSMTRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetOrganizationsRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetVehiclesRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetGunsRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetDrugsRelatedToInfo(aggregateQuery, number, agencyId, module)); relatedToList.AddRange(GetPropertyRelatedToInfo(aggregateQuery, number, agencyId, module)); return(relatedToList); }
public CaseNavigationGraph GetGraphFromReport(Guid reportId) { var report = _reportContext.Find <Report>(reportId); var moduleType = report.ModuleType; var reportHasCaseNumber = !string.IsNullOrWhiteSpace(report.CaseNumber); var reportHasNumber = !string.IsNullOrWhiteSpace(report.Number); #region Report Has Case if (reportHasCaseNumber) { // Find the Case var cCase = _summaryContext.GetEntityQuery <Domain.Summaries.Case.Case>() .FirstOrDefault(CaseSpecifications.ByNumber(report.AgencyId, report.CaseNumber)); // Return the graph for the Case. if (cCase != null) { return(GetGraphFromCase(cCase.Id)); } // We should not be here. Log.Info("Report [{0}] References Case Number [{1}] that does not exist.", report.Id, report.CaseNumber); } #endregion // If there is no Number, build the graph. if (!reportHasNumber) { return(CaseNavigationGraphFactory.BuildNavigationGraph(null, null, new List <Report>() { report })); } #region Report Has Number // Find the Summary var summaries = _summaryContext.GetEntityQuery <Summary>() .Where(SummarySpecifications.ByNumber(report.AgencyId, moduleType, report.Number)) .ToList(); var reports = _reportContext.GetEntityQuery <Report>() .Where(ReportSpecifications.ByNumber(report.AgencyId, moduleType, report.Number)) .ToList(); return(CaseNavigationGraphFactory.BuildNavigationGraph(null, summaries, reports)); #endregion }
public List <RelatedName> GetRelatedOffenders(string number, Guid agencyId) { var offenders = new List <RelatedName>(); var reportOffenders = _reportContext.GetEntityQuery <Report>().Where(ReportSpecifications.ByNumber(agencyId, ModuleType.Incident, number)) .SelectMany(d => d.People.OfType <IncidentPersonSuspect>()).AsListOf <RelatedName>(); var summaryOffenders = _summaryContext.GetEntityQuery <Summary>().Where(SummarySpecifications.ByNumber(agencyId, ModuleType.Incident, number)) .SelectMany(d => d.People.OfType <IncidentPersonSuspect>()).AsListOf <RelatedName>(); offenders.AddRange(reportOffenders); offenders.AddRange(summaryOffenders); return(offenders); }
public List <RelatedName> GetRelatedNames(string number, Guid agencyId, ModuleType module) { var names = new List <RelatedName>(); var reports = _reportContext.GetEntityQuery <Report>().Where(ReportSpecifications.ByNumber(agencyId, module, number)); foreach (var report in reports) { names.AddRange(report.People.AsListOf <RelatedName>()); names.AddRange(report.Organizations.AsListOf <RelatedName>()); } var summaries = _summaryContext.GetEntityQuery <Summary>().Where(SummarySpecifications.ByNumber(agencyId, module, number)); foreach (var summary in summaries) { names.AddRange(summary.People.AsListOf <RelatedName>()); names.AddRange(summary.Organizations.AsListOf <RelatedName>()); } return(names); }
public RelatedToGraph GetRelatedTo(string number, Guid agencyId, ModuleType module) { // Get the Reports with the given number. var reports = _reportContext.GetEntityQuery <Report>() .Where(ReportSpecifications.ByNumber(agencyId, module, number)) .Select( r => new RelatedToItem() { ItemId = r.Id, ModuleType = r.ModuleType, Number = r.Number, RelatedToType = r.IsSupplement ? RelatedToType.SupplementalReport : RelatedToType.InitialReport }); // Get the Summaries with the given number. var summaries = _summaryContext.GetEntityQuery <Summary>() .Where(SummarySpecifications.ByNumber(agencyId, module, number)) .Select(s => new RelatedToItem() { ItemId = s.Id, ModuleType = s.ModuleType, Number = s.Number, RelatedToType = RelatedToType.Summary }); // Build the graph. var graphItems = new List <RelatedToItem>(); graphItems.AddRange(reports); graphItems.AddRange(summaries); var graph = new RelatedToGraph() { Number = number, RelatedItems = graphItems }; return(graph); }
public List <ViolationCodeReference> GetRelatedOffenses(string number, Guid agencyId, ModuleType module) { var offenses = new List <ViolationCodeReference>(); var reports = _reportContext.GetEntityQuery <Report>().Where(ReportSpecifications.ByNumber(agencyId, module, number)); foreach (var report in reports) { foreach (var offense in report.Offenses) { offenses.Add(offense.ViolationCodeReference.As <ViolationCodeReference>()); } } var summaries = _summaryContext.GetEntityQuery <Summary>().Where(SummarySpecifications.ByNumber(agencyId, module, number)); foreach (var summary in summaries) { foreach (var offense in summary.Offenses) { offenses.Add(offense.ViolationCodeReference.As <ViolationCodeReference>()); } } return(offenses); }