|
1 | 1 | using System;
|
| 2 | +using System.Linq; |
2 | 3 | using AutoMapper;
|
3 | 4 | using EMBC.ESS.Utilities.Dynamics.Microsoft.Dynamics.CRM;
|
4 | 5 | using EMBC.Utilities.Extensions;
|
@@ -52,25 +53,18 @@ public Mappings()
|
52 | 53 | ? InsuranceOption.Unknown
|
53 | 54 | : Enum.Parse<InsuranceOption>(((InsuranceOptionOptionSet)s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_insurancecoverage).ToString())))
|
54 | 55 | .ForMember(d => d.NumberOfPets, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_animal_ESSFileid.Count))
|
55 |
| - .ForMember(d => d.CanProvideAccommodation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidelodging)) |
56 |
| - .ForMember(d => d.CanProvideClothing, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideclothing)) |
57 |
| - .ForMember(d => d.CanProvideFood, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidefood)) |
58 |
| - .ForMember(d => d.CanProvideIncidentals, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideincidentals)) |
59 |
| - .ForMember(d => d.CanProvideTransportation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidetransportation)) |
| 56 | + .ForMember(d => d.RequiresClothing, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideclothing.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False)) |
| 57 | + .ForMember(d => d.RequiresFood, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidefood.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False)) |
| 58 | + .ForMember(d => d.RequiresIncidentals, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideincidentals.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False)) |
| 59 | + .ForMember(d => d.RequiresTransportation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidetransportation.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False)) |
| 60 | + .ForMember(d => d.RequiresShelterReferral, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_shelteroptions.GetValueOrDefault(0) == (int)ShelterOptionSet.Referral)) |
| 61 | + .ForMember(d => d.RequiresShelterAllowance, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_shelteroptions.GetValueOrDefault(0) == (int)ShelterOptionSet.Allowance)) |
60 | 62 | .ForMember(d => d.NumberOfSupports, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Count))
|
61 | 63 | .ForMember(d => d.SupportsTotalAmount, opts => opts.Ignore())
|
62 | 64 | .AfterMap((s, d) =>
|
63 | 65 | {
|
64 | 66 | d.RegistrationCompleted = !string.IsNullOrEmpty(d.TaskNumber);
|
65 |
| - decimal total = 0; |
66 |
| - if (s.era_EvacuationFileid != null) |
67 |
| - { |
68 |
| - foreach (var support in s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId) |
69 |
| - { |
70 |
| - total += support.era_totalamount.HasValue ? support.era_totalamount.Value : 0; |
71 |
| - } |
72 |
| - } |
73 |
| - d.SupportsTotalAmount = total; |
| 67 | + d.SupportsTotalAmount = s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Select(s => s.era_totalamount ?? 0).Sum(); |
74 | 68 | });
|
75 | 69 |
|
76 | 70 | Func<int?, string> resolveSupportType = s =>
|
@@ -236,6 +230,18 @@ public enum EraTwoOptions
|
236 | 230 | No = 174360001
|
237 | 231 | }
|
238 | 232 |
|
| 233 | + public enum NeedTrueFalseOptionSet |
| 234 | + { |
| 235 | + True = 174360000, |
| 236 | + False = 174360001 |
| 237 | + } |
| 238 | + |
| 239 | + public enum ShelterOptionSet |
| 240 | + { |
| 241 | + Allowance = 174360000, |
| 242 | + Referral = 174360001 |
| 243 | + } |
| 244 | + |
239 | 245 | #pragma warning restore CA1008 // Enums should have zero value
|
240 | 246 |
|
241 | 247 | public class GenderConverter : IValueConverter<string, int?>, IValueConverter<int?, string>
|
|
0 commit comments