Exemple #1
0
        public static FloodingConfiguration ToConfig(this FloodingRequest request, ConfirmAttributeFormOptions attributesFormOptions, VerintOptions verintOptions)
        {
            var verintConfigValue = request.WhatDoYouWantToReport.Equals("flood") ? request.WhereIsTheFlood : request.WhatDoYouWantToReport;
            var verintConfig      = verintOptions.Options.First(_ => _.Type.Equals(verintConfigValue));

            var formOptions = new ConfirmFloodingIntegrationFormOptions
            {
                EventId     = verintConfig.EventCode,
                ClassCode   = verintConfig.ClassCode,
                ServiceCode = verintConfig.ServiceCode,
                SubjectCode = verintConfig.SubjectCode
            };

            formOptions.FloodingSourceReported = attributesFormOptions.FloodingSourceReported.FirstOrDefault(_ => _.Type.Equals(request.WhereIsTheFloodingComingFrom))?.Value ?? string.Empty;
            formOptions.DomesticOrCommercial   = attributesFormOptions.CommercialOrDomestic.FirstOrDefault(_ => _.Type.Equals(request.WhereIsTheFlood))?.Value ?? string.Empty;

            if (request.WhereIsTheFlood.Equals("home"))
            {
                if (request.WhereInThePropertyIsTheFlood.Equals("garage"))
                {
                    formOptions.LocationOfFlooding =
                        attributesFormOptions.FloodLocationInProperty.First(_ =>
                                                                            _.Type.Equals(request.IsTheGarageConnectedToYourHome)).Value;
                }
                else
                {
                    formOptions.LocationOfFlooding = attributesFormOptions.FloodLocationInProperty
                                                     .First(_ => _.Type.Equals(request.WhereInThePropertyIsTheFlood)).Value;
                }
            }

            if (request.WhereIsTheFlood.Equals("business"))
            {
                if (request.IsTheFloodInsideOrOutsideProperty.Equals("inside"))
                {
                    formOptions.LocationOfFlooding = attributesFormOptions.FloodLocationInProperty
                                                     .First(_ => _.Type.Equals(request.WhereInThePropertyIsTheFlood)).Value;
                }
                else
                {
                    formOptions.LocationOfFlooding = attributesFormOptions.FloodLocationInProperty
                                                     .First(_ => _.Type.Equals("garden")).Value;
                }
            }

            formOptions.XCoordinate = request.Map?.Lng;
            formOptions.YCoordinate = request.Map?.Lat;

            return(new FloodingConfiguration
            {
                ConfirmIntegrationFormOptions = formOptions,
                VerintOption = verintConfig
            });
        }
        public ConfirmIntegrationFormOptionsMapperTests()
        {
            _verintOptions = new VerintOptions
            {
                Options = new List <Option>
                {
                    new Option
                    {
                        EventCode   = 111111,
                        Type        = "pavement",
                        ServiceCode = "HWAY",
                        SubjectCode = "CWFD",
                        ClassCode   = "SERV"
                    },
                    new Option
                    {
                        EventCode   = 222222,
                        Type        = "home",
                        ServiceCode = "HWAY",
                        SubjectCode = "CWFD",
                        ClassCode   = "SERV"
                    },
                    new Option
                    {
                        EventCode   = 333333,
                        Type        = "road",
                        ServiceCode = "HWAY",
                        SubjectCode = "CWFD",
                        ClassCode   = "SERV"
                    },
                    new Option
                    {
                        EventCode   = 4444444,
                        Type        = "business",
                        ServiceCode = "HWAY",
                        SubjectCode = "CWFD",
                        ClassCode   = "SERV"
                    }
                }
            };

            _confirmAttributeFormOptions = new ConfirmAttributeFormOptions
            {
                FloodingSourceReported = new List <Config>
                {
                    new Config
                    {
                        Type  = "river",
                        Value = "RIV"
                    },
                    new Config
                    {
                        Type  = "culverted",
                        Value = "CULV"
                    }
                },
                FloodLocationInProperty = new List <Config>
                {
                    new Config
                    {
                        Type  = "cellarOrBasement",
                        Value = "BAS"
                    },
                    new Config
                    {
                        Type  = "driveway",
                        Value = "DRV"
                    },
                    new Config
                    {
                        Type  = "yes",
                        Value = "GARA"
                    },
                    new Config
                    {
                        Type  = "garden",
                        Value = "GAR"
                    }
                },
                CommercialOrDomestic = new List <Config>
                {
                    new Config
                    {
                        Type  = "home",
                        Value = "DOM"
                    },
                    new Config
                    {
                        Type  = "business",
                        Value = "COM"
                    }
                }
            };
        }