Ejemplo n.º 1
0
 public async Task<GeocodeDto> ReverseGeocode(GetGeocodeInput input)
 {
     if(input.Latitude.HasValue && input.Longitude.HasValue)
     {
         return GeocodeByLatLong(input.Latitude.Value, input.Longitude.Value);
     }
     return new GeocodeDto();
 }
        public async Task<Dtos.SubscribersDto> CreateSubscribers(Dtos.CreateSubscribersInput input)
        {
            //Find Geocoding
            GetGeocodeInput inputGeocode = new GetGeocodeInput()
            {
                Address1 = input.AddressLine1,
                Address2 = input.AddressLine2,
                City = input.City,
                State = input.State,
                Zip = input.AreaCode
            };
            var geocodeResults = await _geocodingService.GeocodeAddress(inputGeocode);

            //We can use Logger, it's defined in ApplicationService class.
            //ERROR:  Logger.Info("Creating a task for input: " + input);

            //Creating a new Task entity with given input's properties
            var Subscribers = new Subscriber { 
                FullName = input.FullName,
                SmsNumber = input.SmsNumber,
                Email = input.Email,
                ApiKey = input.ApiKey.HasValue ? input.ApiKey.Value : Guid.Empty,
                Latitude = geocodeResults.Latitude,
                Longitude = geocodeResults.Longitude
            };

            //Saving entity with standard Insert method of repositories.
            int SubscribersId = _subscribersRepository.InsertAndGetId(Subscribers);

            return new Dtos.SubscribersDto
            {
                FullName = input.FullName,
                SmsNumber = input.SmsNumber,
                Email = input.Email,
                Id = SubscribersId,
                Longitude = geocodeResults.Longitude,
                Latitude = geocodeResults.Latitude
            };
        }
Ejemplo n.º 3
0
 public async Task<GeocodeDto> GeocodeAddress(GetGeocodeInput input)
 {
     string address = String.Format("{0} {1} {2} {3} {4} ", 
         input.Address1, input.Address2, input.City, input.State, input.Zip, input.Country);
     return GeocodeByAddress(address);
 }