Base solution for your next web application
Open Closed

Leverage current framework to automatically return response. #4399


User avatar
0
rattlehub created

I have service that i want to call that calls the bing rss service.

I have exposed it in the .Application project as follows

public ListResultDto<AddressListDto> GetAddresByString(string input) { var address = new List<Address>(); var locationService = new BingMaps.BingGeoSpatialService(); var bingAddresses = locationService.GetLocationsByQueryAsync(input).Result; if (bingAddresses?.EstimatedTotal > 0) { foreach (var location in bingAddresses.Locations) { var foundAddress = new Address(); if (AbpSession.UserId != null) { foundAddress.UserId = AbpSession.UserId.Value; } foundAddress.AddressLine1 = location.Address.AddressLine; foundAddress.AdminDistrict = location.Address.AdminDistrict; foundAddress.AdminDistrict2 = location.Address.AdminDistrict2; foundAddress.City = location.Address.Locality; foundAddress.Country = location.Address.CountryRegion; foundAddress.FormattedAddress = location.Address.FormattedAddress; if (location.GeocodePoints?.Count > 0) { foundAddress.Latitude = (decimal)location.GeocodePoints[0].Coordinates[0]; foundAddress.Longitude = (decimal)location.GeocodePoints[0].Coordinates[1]; } address.Add(foundAddress); } }

        return new ListResultDto&lt;AddressListDto&gt;(address.MapTo&lt;List&lt;AddressListDto&gt;>());
    }

This seems to expose it perfectly but if i call abp.services.app.address.getAddresByString("Bukingham palace, england"); it seems to return immediately. Do you have a example where i can leverage the framework to expose logic and return the result to the browser (console); Basically im trying to use the framework to expose javascript functions


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    It returns a Promise. You can use Client Proxies like that:

    abp.services.app.address.getAddresByString("Bukingham palace, england").done(function (result) {
        console.log(result);
    });
    
  • User Avatar
    0
    rattlehub created

    Thanks. Works perfectly