コード例 #1
0
        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);
            }
        }