예제 #1
0
        public async Task <FWTObjectID> CreateAsync(StockportGovUK.NetStandard.Models.Verint.Organisation organisation)
        {
            _logger.LogDebug($"OrganisationService.Create: Attempting to Create - { organisation.Name }");

            if (organisation.Address != null)
            {
                organisation.Address.UPRN = await _propertyService.CheckUPRNForId(organisation.Address);
            }

            var fwtOrganisation = organisation.Map();
            var response        = await _verintConnection.createOrganisationAsync(fwtOrganisation);

            _logger.LogDebug($"OrganisationService.ResolveOrganisation: Created new organisation - { fwtOrganisation.Name.First().FullName }, { response.FLNewOrganisationID.ObjectReference.First() }");
            return(response.FLNewOrganisationID);
        }
        public async Task <FWTObjectID> ResolveAsync(Customer customer)
        {
            // HACK: Check whether UPRN provided is actually an ID and if so lookup the reals UPRN
            if (customer.Address != null)
            {
                customer.Address.UPRN = await _propertyService.CheckUPRNForId(customer.Address);
            }

            if (string.IsNullOrEmpty(customer.Forename) || string.IsNullOrEmpty(customer.Surname))
            {
                return(await CreateAsync(customer));
            }

            var individual = await FindAsync(customer);

            if (individual == null)
            {
                _logger.LogDebug($"IndividualService.ResolveIndividual: No match - Creating new individual - Customer {customer.Surname}");

                return(await CreateAsync(customer));
            }

            return(individual);
        }