Esempio n. 1
0
 public void CommonFormats_EmptyName()
 {
     _fullName = CommonFormats.FullName(null, null, null, null);
     Assert.IsTrue(string.IsNullOrEmpty(_fullName));
 }
Esempio n. 2
0
 public void CommonFormats_NameWithoutMiddleNameAndSuffix()
 {
     _fullName = CommonFormats.FullName(LastName, FirstName, null, null);
     Assert.IsNotNull(_fullName);
     Assert.AreEqual(string.Concat(LastName, ",", " ", FirstName), _fullName);
 }
Esempio n. 3
0
 public void CommonFormats_NameWithoutLastNameAndFirstName()
 {
     _fullName = CommonFormats.FullName(null, null, MiddleName, Suffix);
     Assert.IsNotNull(_fullName);
     Assert.AreEqual(string.Concat(" ", MiddleName, " ", Suffix), _fullName);
 }
Esempio n. 4
0
 public void CommonFormats_FullName()
 {
     _fullName = CommonFormats.FullName(LastName, FirstName, MiddleName, Suffix);
     Assert.IsNotNull(_fullName);
     Assert.AreEqual(string.Concat(LastName, ",", " ", FirstName, " ", MiddleName, " ", Suffix), _fullName);
 }
Esempio n. 5
0
        // Configure Mapper
        protected override void Configure()
        {
            #region Report => ReportQueueItem

            // This is the mapping for the common generic "report/workflow" queue data.
            CreateMap <Report, ReportQueueItem>()
            .ForMember(d => d.Number, o => o.MapFrom(s => ReportInfoFormatter.FormatReportNumber(s)))
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => string.IsNullOrWhiteSpace(s.CaseNumber) ? NoCaseAssigned : s.CaseNumber))
            .ForMember(d => d.Agency, o => o.MapFrom(s => ReferenceDataHelper.GetOri(s.AgencyId)))
            .ForMember(d => d.Priority, o => o.MapFrom(s => s.Priority.GetDescription()))
            .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.Event.Description.Description))
            .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description))
            .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress))
            .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description))
            .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description))
            .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description))
            .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.Event == null ? string.Empty : CommonFormats.StandardDateTime(s.Event.StartDate)))
            .AfterMap((report, result) =>
            {
                var reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault(x => string.Compare(x.InvolvementType.Code, OfficerInvolvementTypes.Reporting.Code, StringComparison.InvariantCultureIgnoreCase) == 0);
                if (reportingOfficer == null)
                {
                    reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault();
                }
                if (reportingOfficer != null)
                {
                    result.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    result.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                }
            });
            #endregion

            #region Case => CaseQueueItem

            // TODO DateTime Format

            CreateMap <Case, CaseQueueItem>()
            .ForMember(d => d.Location, o => o.MapFrom(s => s.Location.StreetAddress))
            .ForMember(d => d.CrimeType, o => o.MapFrom(s => s.CrimeType.Description))
            .AfterMap((@case, item) =>
            {
                item.Agency = ReferenceDataHelper.GetOri(@case.AgencyId);

                // TODO Primary Offense...???
                item.PrimaryOffense = string.Empty;    //"TODO";

                // TODO Related Cases???
                item.RelatedCases = string.Empty;     //"TODO";
            });

            #endregion

            #region ArrestSummary => ArrestSummaryQueueItem

            CreateMap <ArrestSummary, ArrestSummaryQueueItem>()
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number))
            .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.ArrestEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.ArrestEvent.StartDate)))
            .ForMember(d => d.EventLocationBeat, o => o.MapFrom(s => s.Event.Address.Beat.Description))
            .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description))
            .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress))
            .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description))
            .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description))
            .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description))
            .AfterMap((summary, info) =>
            {
                info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId);

                var arrestee = summary.Arrestee;
                if (arrestee != null)
                {
                    info.Arrestee = arrestee.FullName;
                    info.DateBorn = arrestee.DateOfBirth;
                    info.Sex      = arrestee.Sex.Description;
                    info.Race     = arrestee.Race.Description;
                }

                var charge = summary.ArrestCharges.FirstOrDefault();
                if (charge != null)
                {
                    //info.Charge = charge.Description;}
                    info.Charge = charge.ViolationCodeReference.Description;
                }

                var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code);
                if (reportingOfficer != null)
                {
                    info.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    info.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                    info.EventDateReported    = reportingOfficer.InvolvementDate;
                }

                var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code);
                if (supplementingOfficer != null)
                {
                    info.SupplementingOfficerId   = supplementingOfficer.OfficerName.Code;
                    info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description;
                }
            });

            #endregion

            #region IncidentSummary => IncidentSummaryQueueItem

            CreateMap <IncidentSummary, IncidentSummaryQueueItem>()
            .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.IncidentEvent == null ? null : s.IncidentEvent.StartDate))
            .ForMember(d => d.Status, o => o.MapFrom(s => s.IncidentEvent.Status.Description))
            .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.IncidentEvent.Description.Description))
            .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.IncidentEvent.Address.CommonplaceName.Description))
            .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.IncidentEvent.Address.StreetAddress))
            .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.IncidentEvent.Address.City.Description))
            .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.IncidentEvent.Address.State.Description))
            .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.IncidentEvent.Address.ZipCode.Description))
            .AfterMap((summary, info) =>
            {
                info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId);

                var suspect = summary.Suspects.FirstOrDefault();
                if (suspect != null)
                {
                    info.Suspect = suspect.FullName;
                }

                var offense = summary.Offenses.FirstOrDefault();
                if (offense != null)
                {
                    //info.Offense = offense.Description;}
                    info.Offense = offense.ViolationCodeReference.Description;
                }

                var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code);
                if (approvingOfficer != null)
                {
                    info.ApprovingOfficerId   = approvingOfficer.OfficerName.Code;
                    info.ApprovingOfficerName = approvingOfficer.OfficerName.Description;
                }

                var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code);
                if (assistingOfficer != null)
                {
                    info.AssistingOfficerId   = assistingOfficer.OfficerName.Code;
                    info.AssistingOfficerName = assistingOfficer.OfficerName.Description;
                }

                var investigatingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Investigating.Code);
                if (investigatingOfficer != null)
                {
                    info.InvestigatingOfficerId   = investigatingOfficer.OfficerName.Code;
                    info.InvestigatingOfficerName = investigatingOfficer.OfficerName.Description;
                }

                var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code);
                if (reportingOfficer != null)
                {
                    info.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    info.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                    info.EventDateReported    = reportingOfficer.InvolvementDate;
                }


                var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code);
                if (supplementingOfficer != null)
                {
                    info.SupplementingOfficerId   = supplementingOfficer.OfficerName.Code;
                    info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description;
                }
            });

            #endregion

            #region FieldInterviewSummary => FieldInterviewQueueItem

            CreateMap <FieldInterviewSummary, FieldInterviewSummaryQueueItem>()
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number))
            .ForMember(d => d.IntelligenceConcerning, o => o.MapFrom(s => s.FieldInterviewEvent == null ? string.Empty : s.FieldInterviewEvent.IntelligenceConcerning))
            .ForMember(d => d.ReasonForContact, o => o.MapFrom(s => s.FieldInterviewEvent == null
                    ? string.Empty
                    : (s.FieldInterviewEvent.ReasonsForContact.FirstOrDefault() == null
                    ? string.Empty
                    : s.FieldInterviewEvent.ReasonsForContact.First().Description)))
            .ForMember(d => d.DateTimeContact, o => o.MapFrom(s => s.FieldInterviewEvent == null
                    ? string.Empty
                    : CommonFormats.StandardDateTime(s.FieldInterviewEvent.StartDate)))
            .ForMember(d => d.InfoEvaluation, o => o.MapFrom(s => s.FieldInterviewEvent.InfoEvaluation.Description))
            .ForMember(d => d.LocationCommonplaceName, o => o.MapFrom(s => s.FieldInterviewEvent.Address.CommonplaceName.Description))
            .ForMember(d => d.LocationCity, o => o.MapFrom(s => s.FieldInterviewEvent.Address.City.Description))
            .ForMember(d => d.LocationState, o => o.MapFrom(s => s.FieldInterviewEvent.Address.State.Description))
            .ForMember(d => d.LocationZipCode, o => o.MapFrom(s => s.FieldInterviewEvent.Address.ZipCode.Description))
            .ForMember(d => d.LocationStreetAddress, o => o.MapFrom(s => s.FieldInterviewEvent.Address.StreetAddress))
            .AfterMap((summary, result) =>
            {
                // Find the first ReasonForContact.
                var reasonForContact = summary.FieldInterviewEvent != null ? summary.FieldInterviewEvent.ReasonsForContact.FirstOrDefault() : null;
                if (reasonForContact != null)
                {
                    result.ReasonForContact = reasonForContact.Description;
                }

                // Find the first Source.
                var source = summary.FieldInterviewSources.FirstOrDefault();
                if (source != null)
                {
                    result.Sex         = source.Sex.Description;
                    result.Race        = source.Race.Description;
                    result.DateBorn    = source.DateOfBirth;
                    result.ContactName = CommonFormats.FullName(source.LastName, source.FirstName, source.MiddleName, source.Suffix);
                }

                var reportingOfficer = summary.Officers.ReportingOfficers().FirstOrDefault();
                if (reportingOfficer != null)
                {
                    result.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    result.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                }

                var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code);
                if (supplementingOfficer != null)
                {
                    result.SupplementingOfficerId   = supplementingOfficer.OfficerName.Code;
                    result.SupplementingOfficerName = supplementingOfficer.OfficerName.Description;
                }
            });

            #endregion

            #region CitationSummary => CitationSummaryQueueItem

            CreateMap <CitationSummary, CitationSummaryQueueItem>()
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number))
            .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.Event == null ? string.Empty : CommonFormats.StandardDateTime(s.Event.StartDate)))
            .ForMember(d => d.EventLocationBeat, o => o.MapFrom(s => s.Event.Address.Beat.Description))
            .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.Event.Description.Description))
            .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description))
            .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress))
            .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description))
            .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description))
            .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description))
            .ForMember(d => d.EventLocationCounty, o => o.MapFrom(s => s.Event.Address.County.Description))

            .ForMember(d => d.IsVoided, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.IsVoided.Description))
            .ForMember(d => d.ReadyForPublish, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.ReadyForPublish.Description))
            .ForMember(d => d.ReadyForCourt, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.ReadyForCourt.Description))
            .ForMember(d => d.CitationDescription, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.CitationDescription.Description))
            .ForMember(d => d.CitationType, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.CitationType.Description))
            .ForMember(d => d.CourtDate, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.CitationEvent.CourtDate)))

            .AfterMap((summary, info) =>
            {
                info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId);

                var subject = summary.Subject;
                if (subject != null)
                {
                    info.Subject  = subject.FullName;
                    info.DateBorn = subject.DateOfBirth;
                    info.Sex      = subject.Sex.Description;
                    info.Race     = subject.Race.Description;
                }

                //put list of all charges and concat together

                /*
                 * var charge = summary.CitationCharges.ToList();
                 * var dex = 1;
                 * foreach (var citationCharge in charge)
                 * {
                 *  info.Charge = info.Charge +  "[Charge: "  +   dex   +  "] " + citationCharge.ViolationCodeReference.Description + "  \n";
                 *  dex++;
                 * }
                 */

                var offense = summary.Offenses.FirstOrDefault();
                if (offense != null)
                {
                    info.Charge = offense.ViolationCodeReference.Description;
                }

                var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code);
                if (reportingOfficer != null)
                {
                    info.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    info.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                    info.EventDateReported    = reportingOfficer.InvolvementDate;
                }

                var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code);
                if (approvingOfficer != null)
                {
                    info.ApprovingOfficerId   = approvingOfficer.OfficerName.Code;
                    info.ApprovingOfficerName = approvingOfficer.OfficerName.Description;
                }

                var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code);
                if (assistingOfficer != null)
                {
                    info.AssistingOfficerId   = assistingOfficer.OfficerName.Code;
                    info.AssistingOfficerName = assistingOfficer.OfficerName.Description;
                }

                var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code);
                if (supplementingOfficer != null)
                {
                    info.SupplementingOfficerId   = supplementingOfficer.OfficerName.Code;
                    info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description;
                }
            });

            #endregion

            #region CallForServiceSummary => CallForServiceSummaryQueueItem

            CreateMap <CallForServiceSummary, CallForServiceSummaryQueueItem>()
            .ForMember(d => d.Beat, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.Beat.Description))
            .ForMember(d => d.CallStatus, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.WhichQueue.Description))
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number))
            // TODO:  map derived field CasePendingTime
            .ForMember(d => d.City, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.City.Description))
            .ForMember(d => d.CommonplaceName, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.CommonplaceName.Description))
            // TODO:  map derived field Disposition
            .ForMember(d => d.EnteredBy, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.CallTakingPerformedBy.Description))
            .ForMember(d => d.EventDate, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.CallForServiceEvent.StartDate)))
            .ForMember(d => d.CallPriority, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Priority.Description))
            // TODO:  map derived field ReportStatus
            .ForMember(d => d.SituationFound, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.SituationFound.Description))
            .ForMember(d => d.SituationReported, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Problem.Description))
            .ForMember(d => d.State, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.State.Description))
            .ForMember(d => d.StreetAddress, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.StreetAddress))
            .ForMember(d => d.ZipCode, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.ZipCode.Description))
            .AfterMap((summary, info) =>
            {
                info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId);

                // Map derived field Responders
                //string returnstring = string.Empty;
                string returnstring = string.Empty;
                if (summary.CallForServiceResponses != null)
                {
                    foreach (CallForServiceResponse r in summary.CallForServiceResponses)
                    {
                        if (summary.CallForServiceResponses.Count > 1)
                        {
                            returnstring += " [";
                        }

                        if (r.AssociatedResponders != null)
                        {
                            int responderCount = 1;
                            foreach (AssociatedResponder ar in r.AssociatedResponders)
                            {
                                if (responderCount == 1)
                                {
                                    returnstring += string.Format("{0}", ar.Name);
                                }
                                else
                                {
                                    returnstring += " / " + string.Format("{0}", ar.Name);
                                }
                                responderCount++;
                            }
                        }

                        if (summary.CallForServiceResponses.Count > 1)
                        {
                            returnstring += "] ";
                        }
                    }
                }
                info.Responders = returnstring.Trim();
            });

            #endregion

            #region OtherEventSummary => OtherEventSummaryQueueItem

            CreateMap <OtherEventSummary, OtherEventSummaryQueueItem>()
            .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number))
            .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.OtherEventEvent == null ? null : s.OtherEventEvent.StartDate))
            .ForMember(d => d.EventCategory, o => o.MapFrom(s => s.OtherEventEvent.EventCategory.Description))
            .ForMember(d => d.EventStatus, o => o.MapFrom(s => s.OtherEventEvent.EventStatus.Description))
            .ForMember(d => d.CommonplaceName, o => o.MapFrom(s => s.OtherEventEvent.Address.CommonplaceName.Description))
            .ForMember(d => d.StreetAddress, o => o.MapFrom(s => s.OtherEventEvent.Address.StreetAddress))
            .ForMember(d => d.City, o => o.MapFrom(s => s.OtherEventEvent.Address.City.Description))
            .ForMember(d => d.State, o => o.MapFrom(s => s.OtherEventEvent.Address.State.Description))
            .ForMember(d => d.ZipCode, o => o.MapFrom(s => s.OtherEventEvent.Address.ZipCode.Description))
            .ForMember(d => d.County, o => o.MapFrom(s => s.OtherEventEvent.Address.County.Description))
            .ForMember(d => d.Beat, o => o.MapFrom(s => s.OtherEventEvent.Address.Beat.Description))
            .ForMember(d => d.Description, o => o.MapFrom(s => s.OtherEventEvent.Description.Description))
            .AfterMap((summary, info) =>
            {
                info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId);

                var subject = summary.People.FirstOrDefault();
                if (subject != null)
                {
                    info.Subject = subject.FullName;
                }

                var offense = summary.Offenses.FirstOrDefault();
                if (offense != null)
                {
                    info.Charge = offense.ViolationCodeReference.Description;
                }

                var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code);
                if (reportingOfficer != null)
                {
                    info.ReportingOfficerId   = reportingOfficer.OfficerName.Code;
                    info.ReportingOfficerName = reportingOfficer.OfficerName.Description;
                }

                var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code);
                if (supplementingOfficer != null)
                {
                    info.SupplementingOfficerId   = supplementingOfficer.OfficerName.Code;
                    info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description;
                }

                var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code);
                if (assistingOfficer != null)
                {
                    info.AssistingOfficerId   = assistingOfficer.OfficerName.Code;
                    info.AssistingOfficerName = assistingOfficer.OfficerName.Description;
                }

                var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code);
                if (approvingOfficer != null)
                {
                    info.ApprovingOfficerId   = approvingOfficer.OfficerName.Code;
                    info.ApprovingOfficerName = approvingOfficer.OfficerName.Description;
                }
            });

            #endregion
        }
Esempio n. 6
0
 public void CommonFormats_NameWithoutSuffix()
 {
     fullName = CommonFormats.FullName(lastName, firstName, middleName, null);
     Assert.IsNotNull(fullName);
     Assert.AreEqual(string.Concat(lastName, ",", " ", firstName, " ", middleName), fullName);
 }
Esempio n. 7
0
 public void CommonFormats_NameWithoutLastName()
 {
     fullName = CommonFormats.FullName(null, firstName, middleName, suffix);
     Assert.IsNotNull(fullName);
     Assert.AreEqual(string.Concat(" ", firstName, " ", middleName, " ", suffix), fullName);
 }
Esempio n. 8
0
        // Configure Mapper
        protected override void Configure()
        {
            #region CodeSet
            CreateMap <CodeSet, Contracts.Administration.DTO.CodeSetAdmin.CodeSet>();
            #endregion

            #region Code
            CreateMap <CodeDetails, Code>()
            .AfterMap((dto, code) => code.SetLifetime(dto.ActiveOn, dto.InactiveAfter));
            CreateMap <Code, Contracts.Administration.DTO.CodeSetAdmin.Code>();
            #endregion

            #region Ucr and Violation Code

            CreateMap <UcrCode, UcrCodeDetails>();
            CreateMap <UcrCodeDetails, UcrCode>();
            CreateMap <UcrCodeDetails, UCRCodeReference>();

            CreateMap <ViolationCode, ViolationCodeDetails>();
            CreateMap <ViolationCodeDetails, ViolationCode>();

            #endregion

            #region NCICCode

            CreateMap <NCICCode, NCICCodeDetails>();
            CreateMap <NCICCodeDetails, NCICCode>();

            #endregion

            #region ImageInfo

            CreateMap <ImageInfo, ImageInfoDetails>();
            CreateMap <ImageInfoDetails, ImageInfo>();

            #endregion

            #region ContactInfo

            CreateMap <ContactInfo, Domain.Administration.ValueObjects.ContactInfo>();
            CreateMap <Domain.Administration.ValueObjects.ContactInfo, ContactInfo>();
            #endregion

            #region Role
            CreateMap <RoleDetails, Role>().IgnorePrivateAndProtectedSetters();
            CreateMap <Role, Contracts.Administration.DTO.RoleAdmin.Role>()
            .IgnorePrivateAndProtectedSetters()
            .ForMember(d => d.ModulePermissions, o => o
                       .MapFrom(s => s.ModulePermissions.ToDictionary(permission => permission.ModuleType, permission => permission.Permissions)));
            #endregion

            #region Permissions
            CreateMap <ModulePermissions, Domain.Administration.Aggregates.Agency.ValueObjects.ModulePermissions>().ReverseMap();
            CreateMap <AgencyPermissions, Domain.Administration.Aggregates.Agency.ValueObjects.AgencyPermissions>().ReverseMap();
            #endregion

            #region User

            // Map User Details into a User Entity. Also map User details into the Officer Entity
            CreateMap <UserDetails, User>()
            .IgnorePrivateAndProtectedSetters()
            .AfterMap((details, user) => { if (user.AgencyOfficer != null)
                                           {
                                               details.MapInto(user.AgencyOfficer);
                                           }
                      });

            // Map User Details into an Officer Entity.
            CreateMap <UserDetails, Officer>()
            .ForMember(d => d.Name, o => o.MapFrom(s => CommonFormats.FullName(s.LastName, s.FirstName, s.MiddleName, null)))
            .IgnorePrivateAndProtectedSetters();

            // Map User Information into a User DTO.
            // Also Map Officer information into the User DTO.
            CreateMap <User, Contracts.Administration.DTO.UserAdmin.User>()
            .BeforeMap((user, dto) => user.AgencyOfficer.MapInto(dto))     // Map Officer Information
            .ForMember(d => d.Roles,
                       o => o.MapFrom(s => s.AssignedRoles
                                      .Select(x => x.Role)
                                      .Select(Projections.Role.Reference)
                                      .ToList()));

            // Map Officer Information into a User DTO.
            CreateMap <Officer, Contracts.Administration.DTO.UserAdmin.User>();


            // Map Classic User Details into a User Entity. Also map User details into the Officer Entity
            CreateMap <ClassicUser, User>()
            .IgnorePrivateAndProtectedSetters()
            .AfterMap((details, user) => { if (user.AgencyOfficer != null)
                                           {
                                               details.MapInto(user.AgencyOfficer);
                                           }
                      });

            // Map Classic User Details into an Officer Entity.
            CreateMap <ClassicUser, Officer>()
            .ForMember(d => d.Name, o => o.MapFrom(s => CommonFormats.FullName(s.LastName, s.FirstName, s.MiddleName, null)))
            .IgnorePrivateAndProtectedSetters();
            #endregion

            #region Officer

            CreateMap <Officer, Contracts.Administration.DTO.CodeSetAdmin.Code>()
            .ForMember(x => x.Value, o => o.MapFrom(s => s.OfficerId))
            .ForMember(x => x.Description, o => o.MapFrom(s => string.IsNullOrWhiteSpace(s.OfficerId) ? s.Name : string.Concat(s.Name, " ", s.OfficerId)));


            #endregion

            #region Queue

            // Queue is the Entity
            CreateMap <Queue, Contracts.Administration.DTO.UserAdmin.Queue>();
            CreateMap <QueueDetails, Queue>();

            // TODO: Style should be a value object.
            CreateMap <QueueStyle, Contracts.Administration.DTO.UserAdmin.QueueStyle>().ReverseMap();

            // Queue Configuration is a Value Object of the Queue Entity
            CreateMap <QueueConfiguration, Contracts.Administration.DTO.UserAdmin.QueueConfiguration>()
            .ForMember(d => d.Columns, o => o.MapFrom(s => s.ToList()));
            // Construct a New Value
            CreateMap <Contracts.Administration.DTO.UserAdmin.QueueConfiguration, QueueConfiguration>()
            .AfterMap((configuration, queueConfiguration) =>
            {
                queueConfiguration.Clear();
                configuration.Columns.AsListOf <QueueColumn>().ForEach(queueConfiguration.Add);
            });

            // QueueColumn is a Value Object
            CreateMap <QueueColumn, Contracts.Administration.DTO.UserAdmin.QueueColumn>();

            // Construct a New Value
            CreateMap <Contracts.Administration.DTO.UserAdmin.QueueColumn, QueueColumn>()
            .ConstructUsing(col => new QueueColumn(col.Field, col.Title, col.Hidden, col.Width));

            #endregion

            #region Templates
            TemplateProfile.Load(this);
            #endregion

            #region Workflow
            CreateMap <WorkflowDetails, Workflow>();
            CreateMap <Workflow, Contracts.Administration.DTO.WorkflowAdmin.Workflow>();

            CreateMap <Workflow, WorkflowReference>();

            #region Activity to DTO

            CreateMap <Workflow, Contracts.Administration.DTO.WorkflowAdmin.Workflow>()
            .ForMember(dto => dto.Activities, exp => exp.MapFrom(act => Deserialize(act.Xaml)));

            CreateMap <Activity, IActivity>()
            .Include <Submit, Contracts.Administration.DTO.WorkflowAdmin.Submit>()
            .Include <Review, Contracts.Administration.DTO.WorkflowAdmin.Review>()
            .Include <Notify, Contracts.Administration.DTO.WorkflowAdmin.Notify>()
            .ForMember(dto => dto.Text, exp => exp.MapFrom(a => a.DisplayName));

            CreateMap <Submit, Contracts.Administration.DTO.WorkflowAdmin.Submit>();
            CreateMap <Review, Contracts.Administration.DTO.WorkflowAdmin.Review>();
            CreateMap <Notify, Contracts.Administration.DTO.WorkflowAdmin.Notify>();

            #endregion

            #region DTO to Activity

            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Workflow, Workflow>()
            .ForMember(workflow => workflow.Xaml, o => o.MapFrom(dto => ConstructActivitySequenceXaml(dto.Activities)));

            Mapper.CreateMap <IActivity, Activity>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Submit, Submit>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Review, Review>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Notify, Notify>()
            .ForMember(act => act.DisplayName, exp => exp.MapFrom(dto => dto.Text));

            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Submit, Submit>();
            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Review, Review>();
            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Notify, Notify>();

            #endregion

            #endregion

            #region Agency

            CreateMap <Agency, AgencyReference>()
            .ConvertUsing(Projections.Agency.ToReference);

            CreateMap <AgencyReference, Contracts.Administration.DTO.CodeSetAdmin.Code>()
            .ForMember(x => x.Value, o => o.MapFrom(s => s.Ori))
            .ForMember(x => x.Description, o => o.MapFrom(s => s.Name));

            #endregion

            #region AgencySettings

            CreateMap <SettingValue, AgencySetting>();

            #endregion

            #region AgencyConfiguration

            #region Smtp
            CreateMap <SmtpConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.SmtpConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.SmtpConfiguration, SmtpConfiguration>();
            #endregion

            #region Geo
            CreateMap <GeoConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.GeoConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.GeoConfiguration, GeoConfiguration>();
            #endregion

            #region AgencyConfig

            CreateMap <Domain.Administration.Aggregates.Agency.AgencyConfiguration, Contracts.Administration.DTO.AgencyAdmin.AgencyConfiguration>();
            CreateMap <Contracts.Administration.DTO.AgencyAdmin.AgencyConfiguration, Domain.Administration.Aggregates.Agency.AgencyConfiguration>();
            #endregion


            #region Password

            CreateMap <PasswordConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.PasswordConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.PasswordConfiguration, PasswordConfiguration>();
            #endregion

            CreateMap <TemplateReference, Template>();
            CreateMap <Template, TemplateReference>();
            #endregion

            #region QueryConfiguration

            CreateMap <Contracts.Administration.DTO.QueryAdmin.QueryConfiguration, Domain.Administration.Aggregates.Agency.QueryConfiguration>();
            CreateMap <Contracts.Query.DTO.QueryCategory, Domain.Administration.Aggregates.Agency.QueryCategory>();

            #endregion

            this.ConfigureFromAssembly();
        }