コード例 #1
0
ファイル: MapGetter.cs プロジェクト: DrunkRussianGun/RubSort
 private static RecyclingPoint MergeRecyclingPointInfo(
     RecyclingPoint existingInfo,
     RecyclingPoint newInfo)
 {
     existingInfo.Address            = newInfo.Address ?? existingInfo.Address;
     existingInfo.GeoCoordinate      = newInfo.GeoCoordinate ?? existingInfo.GeoCoordinate;
     existingInfo.Contacts.Email     = newInfo.Contacts.Email ?? existingInfo.Contacts.Email;
     existingInfo.Contacts.Telephone = newInfo.Contacts.Telephone ?? existingInfo.Contacts.Telephone;
     return(existingInfo);
 }
コード例 #2
0
        public RecyclingPoint GetInfo(RecyclingPoint recyclingPoint)
        {
            var apiKey              = configuration[apiKeySetting];
            var apiBaseUrl          = configuration[yandexMapApiBaseUrlSetting];
            var apiOrganizationsUrl = configuration[yandexMapApiOrganizationsUrlSetting];

            // с помощью httpClient отправить запрос по адресу apiBaseUrl + apiOrganizationsUrl
            var response   = httpClient.GetAsync(apiBaseUrl + apiOrganizationsUrl).Result;
            var jsonString = response.Content.ReadAsStringAsync().Result;

            var recyclingPointInfo = new RecyclingPoint();

            // по полученному ответу заполнить recyclingPointInfo
            recyclingPointInfo = JsonConvert.DeserializeObject <RecyclingPoint>(jsonString);

            return(recyclingPointInfo);
        }