public async Task <string> CreateCase(DroppedKerbRequest kerbRequest)
        {
            var crmCase = kerbRequest
                          .ToCase(_VOFConfiguration, _verintOptions);

            var streetResult = await _verintServiceGateway.GetStreet(kerbRequest.StreetAddressDroppedKerb.PlaceRef);

            if (!streetResult.IsSuccessStatusCode)
            {
                throw new Exception("DroppedKerbService.CreateCase: GetStreet status code not successful");
            }

            // confirm uses the USRN for the street,
            // however Verint uses the verint-address-id (Reference) (kerbRequest.StreetAddress.PlaceRef) for streets
            crmCase.Street.USRN = streetResult.ResponseContent.USRN;

            try
            {
                var response = await _verintServiceGateway.CreateVerintOnlineFormCase(crmCase.ToConfirmIntegrationFormCase(_VOFConfiguration));

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("DroppedKerbService.CreateCase: CreateVerintOnlineFormCase status code not successful");
                }

                var person = new Person
                {
                    FirstName = kerbRequest.FirstName,
                    LastName  = kerbRequest.LastName,
                    Email     = crmCase.Customer.Email,
                    Phone     = crmCase.Customer.Telephone
                };


                if (!string.IsNullOrEmpty(person.Email))
                {
                    _mailHelper.SendEmail(
                        person,
                        EMailTemplate.StreetReport,
                        response.ResponseContent.VerintCaseReference,
                        kerbRequest.StreetAddressDroppedKerb);
                }
                return(response.ResponseContent.VerintCaseReference);
            }
            catch (Exception ex)
            {
                throw new Exception($"DroppedKerbService.CreateCase: CRMService CreateDroppedKerbService an exception has occured while creating the case in verint service", ex);
            }
        }
        public async Task <string> CreateCase(AbandonedVehicleReport abandonedVehicleReport)
        {
            var crmCase = abandonedVehicleReport
                          .ToCase(_VOFConfiguration, _verintOptions);

            var streetResult = await _verintServiceGateway.GetStreet(abandonedVehicleReport.StreetAddress.PlaceRef);

            if (!streetResult.IsSuccessStatusCode)
            {
                throw new Exception("AbandonedVehicleService.CreateCase: GetStreet status code not successful");
            }

            // confirm uses the USRN for the street
            // however Verint uses the verint-address-id (Reference) (abandonedVehicleReport.StreetAddress.PlaceRef) for street
            crmCase.Street.USRN = streetResult.ResponseContent.USRN;

            try
            {
                var response = await _verintServiceGateway.CreateVerintOnlineFormCase(crmCase.ToConfirmIntegrationFormCase(_VOFConfiguration));

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("AbandonedVehicleService.CreateCase: CreateVerintOnlineFormCase status code not successful");
                }

                var person = new Person
                {
                    FirstName = abandonedVehicleReport.FirstName,
                    LastName  = abandonedVehicleReport.LastName,
                    Email     = abandonedVehicleReport.Email,
                    Phone     = abandonedVehicleReport.Phone
                };

                _mailHelper.SendEmail(
                    person,
                    EMailTemplate.AbandonedVehicleReport,
                    response.ResponseContent.VerintCaseReference,
                    abandonedVehicleReport.StreetAddress);

                return(response.ResponseContent.VerintCaseReference);
            }
            catch (Exception ex)
            {
                throw new Exception($"AbandonedVehicleService.CreateCase: CRMService CreateAbandonedVehicleService an exception has occured while creating the case in verint service", ex);
            }
        }
Exemple #3
0
        public async Task <string> CreateCase(FloodingRequest request)
        {
            try
            {
                var streetResult = request.DidNotUseMap
                    ? await _streetHelper.GetStreetDetails(request.Reporter.Address)
                    : await _streetHelper.GetStreetUniqueId(request.Map);

                if (!request.DidNotUseMap)
                {
                    request.Map = await ConvertLatLng(request.Map);
                }
                else
                {
                    request.Map = new Map {
                        Lng = streetResult.Easting,
                        Lat = streetResult.Northing
                    };
                }

                var floodingLocationConfig =
                    string.IsNullOrEmpty(request.WhereIsTheFlood) ?
                    _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhatDoYouWantToReport)) :
                    _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhereIsTheFlood));
                var configuration = request.ToConfig(_confirmAttributeFormOptions.Value, _verintOptions.Value);
                var crmCase       = request.ToCase(configuration, streetResult, floodingLocationConfig);
                var verintRequest = crmCase.ToConfirmFloodingIntegrationFormCase(configuration.ConfirmIntegrationFormOptions);

                var caseResult = await _verintServiceGateway.CreateVerintOnlineFormCase(verintRequest);

                _mailHelper.SendEmail(request, caseResult.ResponseContent.VerintCaseReference);

                return(caseResult.ResponseContent.VerintCaseReference);
            }
            catch (Exception ex)
            {
                throw new Exception($"FloodingService:: CreateCase, Failed to create case, exception: {ex.Message}");
            }
        }