public async void RefreshList() { if (IsBusy) { return; } IsBusy = true; isRefreshingList = true; StatusText = "Getting new data..."; AttractionResponse response = await dataService.getAllAttractions(); if (response != null) { if (response.status.Equals("success")) { int colorFlipper = 0; List <AttractionItem> items = new List <AttractionItem>(); foreach (AttractionItem row in response.data) { if (row.image == null || row.image.Length == 0) { row.image = "img_na_placeholder.png"; } if ((colorFlipper % 2) == 0) { row.background = Color.FromHex("#FFFFFF"); } else { row.background = Color.FromHex("#99999D"); } items.Add(row); colorFlipper++; } AttractionsList = new ObservableCollection <AttractionItem>(items); AttractionsList.OrderByDescending(x => x.entry_datetime); if (AttractionsList.Count() > 0) { IsHasDataFlag = false; } else { StatusText = "No Data Available"; IsHasDataFlag = true; } } } else { StatusText = "Service is Unavailable"; } IsBusy = false; isRefreshingList = false; }
public async Task <AttractionResponse> GetAttraction(AttractionRequest attractionRequest, ViatorSetting setting = null) { var uri = $"service/taxonomy/attractions"; var response = await _httpClient.PostAsync <AttractionRequest>(GenerateBaseURL(uri, setting), attractionRequest); if (response.IsSuccessStatusCode) { var content = response.Content.ReadAsStringAsync().Result; var result = AttractionResponse.FromJson(content); if (result.Attractions.Count == 0) { throw new Exception("Viator API - GetAttraction : Empty response return from server"); } return(result); } else { throw new Exception("Viator API - GetAttraction: Api error response"); } }