Esempio n. 1
0
        public IActionResult GetTempPolicy([FromBody] dynamic data)
        {
            TempPolicy tempPolicy = Utils.ConvertTo <TempPolicy>(data);

            string currentCity  = _cityRepository.Retrieve(Int32.Parse(tempPolicy.CityId)).Name;
            string currentState = _stateRepository.Retrieve(tempPolicy.StateId).Name;
            string fullAddress  = tempPolicy.Address1 + " " + tempPolicy.Address2 + " "
                                  + currentCity + " " + currentState + " " + tempPolicy.ZipCode;

            var result = new TempPolicy
            {
                InsuredFirstName           = tempPolicy.InsuredFirstName,
                InsuredMiddleName          = tempPolicy.InsuredMiddleName,
                InsuredLastName            = tempPolicy.InsuredLastName,
                Address                    = fullAddress,
                Address1                   = tempPolicy.Address1,
                Address2                   = tempPolicy.Address2,
                InsuredCity                = currentCity,
                InsuredState               = currentState,
                InsuredZipCode             = tempPolicy.ZipCode,
                PolicyNumber               = tempPolicy.PolicyNumber,
                WildfireAssessmentRequired = false,
                Longitude                  = "",
                Latitude                   = "",
                CityId       = tempPolicy.CityId,
                StateId      = tempPolicy.StateId,
                ZipCode      = tempPolicy.ZipCode,
                InsuredEmail = AppSettings.Configuration["InsuredEmail"]
            };

            result = _mapService.GetAddressGeocode(result);

            return(Ok(result));
        }
        public InspectionOrder ConvertToIO(PolicyXMLResponse policyXML)
        {
            InspectionOrder                newIO              = new InspectionOrder();
            InspectionOrderProperty        newProperty        = new InspectionOrderProperty();
            InspectionOrderPropertyGeneral newPropertyGeneral = new InspectionOrderPropertyGeneral();

            string currentCity  = _cityRepository.RetrieveByName(policyXML.Property.LegalAddress.City, policyXML.Property.LegalAddress.State).Name;
            string currentState = _stateRepository.Retrieve(policyXML.Property.LegalAddress.State).Name;

            string fullAddress = $"{policyXML.Property.LegalAddress.Street1} {currentCity} {currentState} {policyXML.Property.LegalAddress.ZipCode}";

            var insuredName = policyXML.Policy.InsuredName.Split(' ');
            var nameLength  = insuredName.Length;

            var firstName = "";

            for (int i = 0; i < nameLength - 1; i++)
            {
                firstName = firstName + " " + insuredName[i];
            }
            var lastName = insuredName[nameLength - 1];

            //Policy
            Policy newPolicy = new Policy
            {
                PolicyNumber               = policyXML.Policy.PolicyNumber,
                InsuredFirstName           = firstName,
                InsuredLastName            = lastName,
                CoverageA                  = policyXML.Policy.Coverage,
                InceptionDate              = DateTime.Parse(policyXML.Policy.EffectiveDate),
                InsuredState               = currentState,
                InsuredZipCode             = policyXML.Property.LegalAddress.ZipCode,
                InsuredCity                = currentCity,
                Address                    = fullAddress,
                InsuredEmail               = AppSettings.Configuration["InsuredEmail"],
                WildfireAssessmentRequired = false,
                AgencyName                 = policyXML.Agent.Name,
                AgencyPhoneNumber          = policyXML.Agent.Phone.PhoneNumber,
                PropertyValueId            = PropertyValue(policyXML.Policy.Coverage),
                InspectionStatusId         = "PA"
            };

            var completePolicy = _mapService.GetAddressGeocode(newPolicy);

            newPolicy = completePolicy;

            //Property
            newPropertyGeneral.StreetAddress1 = policyXML.Property.LegalAddress.Street1;
            newPropertyGeneral.StreetAddress2 = "";
            newPropertyGeneral.StateId        = policyXML.Property.LegalAddress.State;
            newPropertyGeneral.ZipCode        = policyXML.Property.LegalAddress.ZipCode;
            newPropertyGeneral.CityId         = _cityRepository.RetrieveByName(policyXML.Property.LegalAddress.City, policyXML.Property.LegalAddress.State).Id;

            //Inspection Order
            newIO.CreatedDate     = DateTime.Now.Date;
            newIO.LastUpdatedDate = DateTime.Now.Date;

            var userId = GetUser("underwriter_user");

            newIO.CreatedById = new Guid(userId.Result);

            newIO.Policy           = newPolicy;
            newIO.Property         = newProperty;
            newIO.Property.General = newPropertyGeneral;

            return(newIO);
        }