Example #1
0
        public async Task GetStreetUniqueId_ShouldCallVerintServiceGateway()
        {
            // Arrange
            var map = new Map
            {
                Street = $"{_street}, {_usrn}"
            };

            _mockVerintGateway
            .Setup(_ => _.GetStreetByUsrn(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponse <List <AddressSearchResult> >());

            // Act
            await _streetHelper.GetStreetUniqueId(map);

            // Assert
            _mockVerintGateway.Verify(_ => _.GetStreetByUsrn(It.IsAny <string>()), Times.Once);
        }
Example #2
0
        public async Task <string> CreateCase(FloodingRequest request)
        {
            try
            {
                var streetResult = request.DidNotUseMap
                    ? await _streetHelper.GetStreetDetails(request.Reporter.Address)
                    : await _streetHelper.GetStreetUniqueId(request.Map);

                if (!request.DidNotUseMap)
                {
                    request.Map = await ConvertLatLng(request.Map);
                }
                else
                {
                    request.Map = new Map {
                        Lng = streetResult.Easting,
                        Lat = streetResult.Northing
                    };
                }

                var floodingLocationConfig =
                    string.IsNullOrEmpty(request.WhereIsTheFlood) ?
                    _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhatDoYouWantToReport)) :
                    _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhereIsTheFlood));
                var configuration = request.ToConfig(_confirmAttributeFormOptions.Value, _verintOptions.Value);
                var crmCase       = request.ToCase(configuration, streetResult, floodingLocationConfig);
                var verintRequest = crmCase.ToConfirmFloodingIntegrationFormCase(configuration.ConfirmIntegrationFormOptions);

                var caseResult = await _verintServiceGateway.CreateVerintOnlineFormCase(verintRequest);

                _mailHelper.SendEmail(request, caseResult.ResponseContent.VerintCaseReference);

                return(caseResult.ResponseContent.VerintCaseReference);
            }
            catch (Exception ex)
            {
                throw new Exception($"FloodingService:: CreateCase, Failed to create case, exception: {ex.Message}");
            }
        }