コード例 #1
0
        public async Task <string> CreateFeedbackCase(FeedbackDetails model)
        {
            var events = _feedbackConfig.Value.FeedbackConfigurations;

            var eventCode = string.IsNullOrEmpty(model.CouncilDepartmentSub)
                ? events.FirstOrDefault(_ => _.EventName == model.CouncilDepartment)?.EventCode ?? events.FirstOrDefault(_ => _.EventName == "none")?.EventCode
                : events.FirstOrDefault(_ => _.EventName == model.CouncilDepartmentSub)?.EventCode ?? events.FirstOrDefault(_ => _.EventName == "none")?.EventCode;

            string name  = string.IsNullOrEmpty(model.Name) ? "Not provided" : model.Name;
            string email = string.IsNullOrEmpty(model.Email) ? "Not provided" : model.Email;

            var crmCase = new Case
            {
                EventCode   = (int)eventCode,
                EventTitle  = string.IsNullOrEmpty(model.CouncilDepartmentOther) ? "Feedback" : $"Feedback - {model.CouncilDepartmentOther}",
                Description = $"Name: {name} \nEmail: {email}\n\nFeedback: {model.Feedback}"
            };

            try
            {
                var response = await _verintServiceGateway.CreateCase(crmCase);

                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"ComplimentsComplaintsService CreateFeedbackCase an exception has occured while creating the case in verint service", ex);
            }
        }
コード例 #2
0
        public async Task <string> CreateCase(ParkingEnforcementRequest parkingEnforcementRequest)
        {
            var crmCase = CreateCrmCaseObject(parkingEnforcementRequest);

            try
            {
                var response = await _VerintServiceGateway.CreateCase(crmCase);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Status code not successful");
                }

                Person person = new Person
                {
                    FirstName       = parkingEnforcementRequest.FirstName,
                    LastName        = parkingEnforcementRequest.LastName,
                    Email           = parkingEnforcementRequest.Email,
                    Phone           = parkingEnforcementRequest.Phone,
                    CustomerAddress = parkingEnforcementRequest.CustomersAddress
                };

                _mailHelper.SendEmail(person, EMailTemplate.ParkingEnforcementRequest, response.ResponseContent);
                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"CRMService CreateParkingEnforcementService an exception has occurred while creating the case in verint service", ex);
            }
        }
コード例 #3
0
        public async Task <string> CreateCase(ContactSTARTRequest request)
        {
            if (!verintConfiguration.ClassificationMap.TryGetValue(request.AreaOfConcern.Trim(), out var eventCode))
            {
                throw new Exception("ContactSTARTService.CreateCase: EventCode not found");
            }

            var response = await verintServiceGateway.CreateCase(request.MapToCase(eventCode));

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception($"ContactSTARTService.CreateCase: the status code {response.StatusCode} indicates something has gone wrong when attempting to create a case within verint-service.");
            }

            if (request.IsAboutSelf && !string.IsNullOrEmpty(request.RefereePerson.EmailAddress))
            {
                _ = mailingServiceGateway.Send(new Mail
                {
                    Template = EMailTemplate.ContactStartRequest,
                    Payload  = JsonConvert.SerializeObject(new
                    {
                        Reference = response.ResponseContent,
                        request.RefereePerson.FirstName,
                        RecipientAddress = request.RefereePerson.EmailAddress,
                        Subject          = "Thank you for contacting START"
                    })
                });
            }

            return(response.ResponseContent);
        }
コード例 #4
0
        public async Task <string> CreateCase(LibraryVolunteeringEnquiry enquiry)
        {
            var response = await _verintServiceGateway.CreateCase(enquiry.MapToCase(
                                                                      _verintConfiguration.EventCode,
                                                                      _verintConfiguration.Classification));

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception("LibraryVolunteeringEnquiryService.CreateCase: VerintServiceGateway status code indicated the case was not created.");
            }

            if (!string.IsNullOrEmpty(enquiry.Email))
            {
                _ = _mailingServiceGateway.Send(new Mail
                {
                    Template = EMailTemplate.LibraryVolunteeringEnquiry,
                    Payload  = JsonConvert.SerializeObject(new
                    {
                        enquiry.FirstName,
                        Reference        = response.ResponseContent,
                        RecipientAddress = enquiry.Email,
                        Subject          = "Library Volunteering Enquiry"
                    })
                });
            }

            return(response.ResponseContent);
        }
        public async Task <string> CreateCase(BridgesStructuresReport bridgesStructuresReport)
        {
            Case crmCase = CreateCrmCaseObject(bridgesStructuresReport);

            try
            {
                StockportGovUK.NetStandard.Gateways.Response.HttpResponse <string> response = await _VerintServiceGateway.CreateCase(crmCase);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Status code not successful");
                }

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

                _mailHelper.SendEmail(person, EMailTemplate.BridgesStructuresReport, response.ResponseContent);
                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"CRMService CreateBridgesOrStructuresService an exception has occured while creating the case in verint service", ex);
            }
        }
コード例 #6
0
        public async Task <string> CreateComplaintCase(ComplaintDetails model)
        {
            var events = _complaintsConfig.Value.ComplaintsConfigurations;

            var eventCode = string.IsNullOrEmpty(model.CouncilDepartmentSub)
                ? events.FirstOrDefault(_ => _.EventName == model.CouncilDepartment)?.EventCode ?? events.FirstOrDefault(_ => _.EventName == "none")?.EventCode
                  : events.FirstOrDefault(_ => _.EventName == model.CouncilDepartmentSub)?.EventCode ?? events.FirstOrDefault(_ => _.EventName == "none")?.EventCode;

            var crmCase = new Case
            {
                EventCode   = (int)eventCode,
                EventTitle  = string.IsNullOrEmpty(model.OtherService) ? $"Complaint - {model.ComplainAboutService}" : $"Complaint - {model.OtherService} - {model.ComplainAboutService}",
                Description = model.ComplainAboutDetails,
                Customer    = new Customer
                {
                    Forename  = model.ContactDetails.FirstName,
                    Surname   = model.ContactDetails.LastName,
                    Email     = model.ContactDetails.EmailAddress,
                    Telephone = model.ContactDetails.PhoneNumber,
                    Address   = new Address()
                }
            };

            if (string.IsNullOrEmpty(model.ContactDetails.Address.PlaceRef))
            {
                crmCase.Customer.Address.AddressLine1 = model.ContactDetails.Address.AddressLine1;
                crmCase.Customer.Address.AddressLine2 = model.ContactDetails.Address.AddressLine2;
                crmCase.Customer.Address.City         = model.ContactDetails.Address.Town;
                crmCase.Customer.Address.Postcode     = model.ContactDetails.Address.Postcode;
            }
            else
            {
                var splitAddress = model.ContactDetails.Address.SelectedAddress.Split(",");
                crmCase.Customer.Address.AddressLine1 = splitAddress[0];
                crmCase.Customer.Address.AddressLine2 = splitAddress[1];

                if (splitAddress.Length == 5)
                {
                    crmCase.Customer.Address.AddressLine3 = splitAddress[2];
                    crmCase.Customer.Address.City         = splitAddress[3];
                    crmCase.Customer.Address.Postcode     = splitAddress[4];
                }
                else
                {
                    crmCase.Customer.Address.City     = splitAddress[2];
                    crmCase.Customer.Address.Postcode = splitAddress[3];
                }

                crmCase.Customer.Address.UPRN = model.ContactDetails.Address.PlaceRef;
            }

            try
            {
                _logger.LogWarning($"ComplaintsService.CreateComplaintCase: Attempting to create verint case. {JsonConvert.SerializeObject(crmCase)}");
                var response = await _verintServiceGateway.CreateCase(crmCase);

                SendUserSuccessEmail(model, response.ResponseContent);
                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"ComplimentsComplaintsService CreateComplimentCase an exception has occured while creating the case in verint service", ex);
            }
        }
コード例 #7
0
        public async Task <string> CreateCase(AccessProtectionMarkingsRequest accessProtectionMarkingsRequest)
        {
            var description = $@"FirstName: {accessProtectionMarkingsRequest.FirstName}
                                LastName: { accessProtectionMarkingsRequest.LastName}
                                Email: {accessProtectionMarkingsRequest.Email}
                                Phone: {accessProtectionMarkingsRequest.Phone}
                                FurtherLlocationDetails: {accessProtectionMarkingsRequest.FurtherLocationDetails}";

            if (accessProtectionMarkingsRequest.CustomersAddress != null)
            {
                description += $@"AddressLine1: {accessProtectionMarkingsRequest.CustomersAddress.AddressLine1}
                                AddressLine2: {accessProtectionMarkingsRequest.CustomersAddress.AddressLine2}
                                Town: {accessProtectionMarkingsRequest.CustomersAddress.Town}
                                Postcode: {accessProtectionMarkingsRequest.CustomersAddress.Postcode}
                                SelectedAddress: {accessProtectionMarkingsRequest.CustomersAddress.SelectedAddress}
                                ";
            }

            var crmCase = new Case
            {
                EventCode   = 4000031,
                EventTitle  = "Basic Verint Case",
                Description = description,
                Street      = new Street
                {
                    Reference = accessProtectionMarkingsRequest.StreetAddress.PlaceRef
                }
            };

            if (!string.IsNullOrEmpty(accessProtectionMarkingsRequest.FirstName) && !string.IsNullOrEmpty(accessProtectionMarkingsRequest.LastName))
            {
                crmCase.Customer = new Customer
                {
                    Forename = accessProtectionMarkingsRequest.FirstName,
                    Surname  = accessProtectionMarkingsRequest.LastName
                };

                if (!string.IsNullOrEmpty(accessProtectionMarkingsRequest.Email))
                {
                    crmCase.Customer.Email = accessProtectionMarkingsRequest.Email;
                }

                if (!string.IsNullOrEmpty(accessProtectionMarkingsRequest.Phone))
                {
                    crmCase.Customer.Telephone = accessProtectionMarkingsRequest.Phone;
                }

                if (string.IsNullOrEmpty(accessProtectionMarkingsRequest.CustomersAddress.PlaceRef))
                {
                    crmCase.Customer.Address = new Address
                    {
                        AddressLine1 = accessProtectionMarkingsRequest.CustomersAddress.AddressLine1,
                        AddressLine2 = accessProtectionMarkingsRequest.CustomersAddress.AddressLine2,
                        AddressLine3 = accessProtectionMarkingsRequest.CustomersAddress.Town,
                        Postcode     = accessProtectionMarkingsRequest.CustomersAddress.Postcode,
                    };
                }
                else
                {
                    crmCase.Customer.Address = new Address
                    {
                        Reference = accessProtectionMarkingsRequest.CustomersAddress.PlaceRef,
                        UPRN      = accessProtectionMarkingsRequest.CustomersAddress.PlaceRef
                    };
                }
            }

            try
            {
                var response = await _VerintServiceGateway.CreateCase(crmCase);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception($"AccessProtectionService CreateCase VerintServiceGateway responded with status code {response.StatusCode}");
                }

                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"AccessProtectionService CreateCase an exception has occured while creating the case in verint service", ex);
            }
        }
        public async Task <string> CreateCase(ParkingDispensationRequest parkingDispensationRequest)
        {
            var description = $@"Reason: {parkingDispensationRequest.PurposeOfDispensation}
                                Start date: {parkingDispensationRequest.DispensationDateStart.ToString("dd/MM/yyyy")}
                                End date: {parkingDispensationRequest.DispensationDateEnd.ToString("dd/MM/yyyy")}
                                Start time: {parkingDispensationRequest.DispensationTimeStart.ToString("HH:mm")}
                                End time: {parkingDispensationRequest.DispensationTimeEnd.ToString("HH:mm")}
                                Vehicle information: {parkingDispensationRequest.VehicleDetails}
                                Further location information: {parkingDispensationRequest.LocationDetails}
                                ";


            var crmCase = new Case
            {
                EventCode   = 2002798,
                EventTitle  = "Request for NON enforcement",
                Description = description,
                Street      = new Street
                {
                    Reference = parkingDispensationRequest.StreetAddress?.PlaceRef
                }
            };

            if (!string.IsNullOrEmpty(parkingDispensationRequest.FirstName) && !string.IsNullOrEmpty(parkingDispensationRequest.LastName))
            {
                crmCase.Customer = new Customer
                {
                    Forename = parkingDispensationRequest.FirstName,
                    Surname  = parkingDispensationRequest.LastName,
                };

                if (!string.IsNullOrEmpty(parkingDispensationRequest.Email))
                {
                    crmCase.Customer.Email = parkingDispensationRequest.Email;
                }

                if (!string.IsNullOrEmpty(parkingDispensationRequest.Phone))
                {
                    crmCase.Customer.Telephone = parkingDispensationRequest.Phone;
                }

                if (string.IsNullOrEmpty(parkingDispensationRequest.CustomersAddress?.PlaceRef))
                {
                    crmCase.Customer.Address = new Address
                    {
                        AddressLine1 = parkingDispensationRequest.CustomersAddress?.AddressLine1,
                        AddressLine2 = parkingDispensationRequest.CustomersAddress?.AddressLine2,
                        AddressLine3 = parkingDispensationRequest.CustomersAddress?.Town,
                        Postcode     = parkingDispensationRequest.CustomersAddress?.Postcode,
                    };
                }
                else
                {
                    crmCase.Customer.Address = new Address
                    {
                        Reference = parkingDispensationRequest.CustomersAddress?.PlaceRef,
                        UPRN      = parkingDispensationRequest.CustomersAddress?.PlaceRef
                    };
                }
            }
            try
            {
                var response = await _VerintServiceGateway.CreateCase(crmCase);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Status code not successful");
                }

                Person person = new Person
                {
                    FirstName = parkingDispensationRequest.FirstName,
                    Email     = parkingDispensationRequest.Email,
                };

                _mailHelper.SendEmail(person, EMailTemplate.ParkingDispensationRequest, response.ResponseContent);
                return(response.ResponseContent);
            }
            catch (Exception ex)
            {
                throw new Exception($"CRMService CreateCase an exception has occured while creating the case in verint service", ex);
            }
        }
        public async Task <string> CreateCase(ParkingPermitsRequest parkingPermitsRequest)
        {
            if (!string.IsNullOrEmpty(parkingPermitsRequest.CaseReference))
            {
                HttpResponse <Case> existingVerintCase = await _verintServiceGateway.GetCase(parkingPermitsRequest.CaseReference);

                if (existingVerintCase != null)
                {
                    if (!_permitHelper.hasCaseModified(parkingPermitsRequest, existingVerintCase.ResponseContent))
                    {
                        return(parkingPermitsRequest.CaseReference);
                    }

                    HttpResponse <string> caseClosedResponse = await _verintServiceGateway.CloseCase(new CloseCaseRequest()
                    {
                        CaseReference = parkingPermitsRequest.CaseReference,
                        Description   = PermitConstants.STATUS_CLOSED,
                        ReasonTitle   = PermitConstants.STATUS_CLOSED,
                    });

                    if (!caseClosedResponse.IsSuccessStatusCode)
                    {
                        throw new HttpResponseException(HttpStatusCode.FailedDependency,
                                                        $"{nameof(ParkingPermitsService)}: {nameof(CreateCase)}: " +
                                                        $"{nameof(_verintServiceGateway)} {nameof(_verintServiceGateway.CloseCase)} " +
                                                        $"failed with {caseClosedResponse.StatusCode}");
                    }
                }
            }

            var verintCase = _permitHelper.ConvertPermitRequestToVerintCase(parkingPermitsRequest);

            HttpResponse <string> response = await _verintServiceGateway.CreateCase(verintCase);

            if (!response.IsSuccessStatusCode || string.IsNullOrEmpty(response.ResponseContent))
            {
                throw new HttpResponseException(HttpStatusCode.FailedDependency,
                                                $"{nameof(ParkingPermitsService)}: {nameof(CreateCase)}: " +
                                                $"{nameof(_verintServiceGateway)} {nameof(_verintServiceGateway.CreateCase)} " +
                                                $"failed with {response.StatusCode}");
            }

            var caseRef = response.ResponseContent;

            try
            {
                if (parkingPermitsRequest.File != null && parkingPermitsRequest.File.Any())
                {
                    foreach (var file in parkingPermitsRequest.File)
                    {
                        var attachment = file;
                        var note       = new NoteWithAttachments
                        {
                            CaseRef = long.Parse(caseRef),
                            AttachmentsDescription = attachment.TrustedOriginalFileName,
                            Attachments            = new List <File> {
                                file
                            }
                        };

                        var noteResponse = await _verintServiceGateway.AddNoteWithAttachments(note);

                        if (!noteResponse.IsSuccessStatusCode || noteResponse == null)
                        {
                            throw new HttpResponseException(HttpStatusCode.FailedDependency,
                                                            $"{nameof(ParkingPermitsService)}: {nameof(CreateCase)}: " +
                                                            $"{nameof(_verintServiceGateway)} {nameof(_verintServiceGateway.AddNoteWithAttachments)} " +
                                                            $"failed with {noteResponse.StatusCode}");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"ParkingEnforcementService::AddNoteWithAttachments, an exception has occurred while adding note with attachment to case: {response.ResponseContent}", ex);
            }

            if (!parkingPermitsRequest.CalculatedCost.Equals(PermitConstants.FREE_PRICE))
            {
                try
                {
                    await _distributedCache.SetStringAsync(caseRef, JsonSerializer.Serialize(parkingPermitsRequest),
                                                           new DistributedCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddMinutes(60) });
                }
                catch (Exception exception)
                {
                    throw new HttpResponseException(HttpStatusCode.FailedDependency,
                                                    $"{nameof(ParkingPermitsService)}: {nameof(CreateCase)}: " +
                                                    $"{nameof(_distributedCache)} failed - Verint Case Ref: " +
                                                    $"{caseRef}, message: {exception.Message}");
                }
            }

            if (parkingPermitsRequest.CalculatedCost.Equals(PermitConstants.FREE_PRICE))
            {
                _mailHelper.SendParkingPermitEmail(EMailTemplate.GenericReport, caseRef, parkingPermitsRequest);
            }

            return(caseRef);
        }