private FWTObjectID GetRaisedByObjects(StockportGovUK.NetStandard.Models.Verint.Case crmCase)
        {
            FWTObjectID raisedBy = null;

            if (crmCase.Customer != null && crmCase.RaisedByBehaviour == RaisedByBehaviourEnum.Individual)
            {
                raisedBy = new FWTObjectID
                {
                    ObjectType      = VerintConstants.IndividualObjectType,
                    ObjectReference = new string[] { crmCase.Customer.CustomerReference }
                };
            }
            else if (crmCase.Organisation != null && crmCase.RaisedByBehaviour == RaisedByBehaviourEnum.Organisation)
            {
                raisedBy = new FWTObjectID
                {
                    ObjectType      = VerintConstants.OrganisationObjectType,
                    ObjectReference = new string[] { crmCase.Organisation.Reference }
                };
            }

            _logger.LogDebug($"InteractionService: GetRaisedByObject - Raised By: {raisedBy.ObjectReference.First()}, {raisedBy.ObjectType}");

            return(raisedBy);
        }
        public async Task <long> CreateAsync(StockportGovUK.NetStandard.Models.Verint.Case crmCase)
        {
            _logger.LogDebug($"InteractionService.Create:{crmCase.ID}:Attempting to create interaction, Event {crmCase.EventTitle}, event code {crmCase.EventCode}");
            var interactionDetails = new FWTInteractionCreate
            {
                Channel  = VerintConstants.Channel,
                Verified = false
            };

            if (crmCase.Customer != null && string.IsNullOrEmpty(crmCase.Customer.CustomerReference))
            {
                var individual = await _individualService.ResolveAsync(crmCase.Customer);

                crmCase.Customer.CustomerReference = individual.ObjectReference[0];
            }

            if (crmCase.Organisation != null && string.IsNullOrEmpty(crmCase.Organisation.Reference))
            {
                var organisation = await _organisationService.ResolveAsync(crmCase.Organisation);

                crmCase.Organisation.Reference = organisation.ObjectReference[0];
            }

            if (crmCase.Organisation != null || crmCase.Customer != null)
            {
                interactionDetails.PartyID = GetRaisedByObjects(crmCase);
            }

            var createInteractionResult = await _verintConnection.createInteractionAsync(interactionDetails);

            _logger.LogDebug($"InteractionService.Create:{crmCase.ID}: Created interaction, Id {createInteractionResult.InteractionID} Event {crmCase.EventTitle}, event code {crmCase.EventCode}");

            return(createInteractionResult.InteractionID);
        }
Ejemplo n.º 3
0
        public async Task <string> Create(StockportGovUK.NetStandard.Models.Verint.Case crmCase)
        {
            crmCase.InteractionReference = await _interactionService.CreateAsync(crmCase);

            var caseDetails = _caseToFWTCaseCreateMapper.Map(crmCase);

            try
            {
                var result = _verintConnection.createCaseAsync(caseDetails).Result.CaseReference;
                if (crmCase.UploadNotesWithAttachmentsAfterCaseCreation)
                {
                    _logger.LogError($"CaseService.create: (crmCase.Note.Count) Notes {crmCase.NotesWithAttachments.Count}. ");
                    crmCase.NotesWithAttachments.ForEach(note => note.CaseRef = Convert.ToInt64(result));
                    await CacheNotesWithAttachments(result, crmCase.NotesWithAttachments);
                }
                else
                {
                    crmCase.NotesWithAttachments.ForEach(async note => {
                        note.CaseRef = Convert.ToInt64(result);
                        await CreateNotesWithAttachment(note);
                    });
                }

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"CaseService.Create:{crmCase.ID} Verint create case failed");
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public async Task <int> UpdateTitle(StockportGovUK.NetStandard.Models.Verint.Case crmCase)
        {
            var caseDetails = new FWTCaseUpdate
            {
                CaseReference = crmCase.CaseReference,
                Title         = crmCase.CaseTitle
            };

            try
            {
                var result = await _verintConnection.updateCaseAsync(caseDetails);

                return(result.FWTCaseUpdateResponse);
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, $"CaseService::UpdateTitle: Error when updating Title field, CaseReference: {crmCase.CaseReference}");
                throw;
            }
        }
Ejemplo n.º 5
0
        public async Task <int> UpdateDescription(StockportGovUK.NetStandard.Models.Verint.Case crmCase)
        {
            var caseDetails = new FWTCaseUpdate
            {
                CaseReference = crmCase.CaseReference,
                Description   = crmCase.Description
            };

            try
            {
                var result = await _verintConnection.updateCaseAsync(caseDetails);

                return(result.FWTCaseUpdateResponse);
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "Error when updating Description field");
                throw;
            }
        }