예제 #1
0
        public override async Task OnResume()
        {
            await base.OnResume();

            HttpResponseMessage res;

            try {
                res = await _apiClient.Execute(HttpMethod.Get, Urls.URI + Urls.PLACES);
            }catch {
                await _dialogService.Value.DisplayAlertAsync("Connection Failed...", "", "Ok");

                return;
            }
            Response <Collection <PlaceItemSummary> > resp = await _apiClient.ReadFromResponse <Response <Collection <PlaceItemSummary> > >(res);

            if (resp.IsSuccess)
            {
                Dictionary <int, PlaceItemSummary> placeById = PlaceList.ToDictionary(x => x.Id, x => x);
                foreach (PlaceItemSummary place in resp.Data)
                {
                    if (!placeById.ContainsKey(place.Id))
                    {
                        place.SelectPlaceCommand = SelectPlaceCommand;
                        PlaceList.Add(place);
                    }
                }
            }
            else if (PlaceList.Count == 0)
            {
                await _dialogService.Value.DisplayAlertAsync("Échec de récupération de la liste", "", "OK");
            }
        }