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);
        }