private async Task LoadPlaces()
        {
            try
            {
                _dialogsService.ShowDialog();

                var result = await _apiService.GetAllPlaces();

                if (result.HttpResponse.IsSuccessStatusCode)
                {
                    Places = new ObservableCollection <PlaceModel>(result.Data);
                }
                else
                {
                    await _dialogsService.ShowMessage(AppResources.ApplicationName,
                                                      "Ha ocurrido un error inesperado.");
                }
            }
            catch (Exception)
            {
                await _dialogsService.ShowMessage(AppResources.ApplicationName,
                                                  "Ha ocurrido un error inesperado. Verifique su conexion a internet.");
            }
            finally
            {
                _dialogsService.HideDialog();
            }
        }
Beispiel #2
0
        private async Task LoadData()
        {
            try
            {
                _dialogsService.ShowLoading();
                List <ActivityModel> result;
                if (_context.UseCloud)
                {
                    var response = await _apiService.GetAllActivities();

                    result = response.Data;
                }
                else
                {
                    result = await _localDatabaseService.GetAllActivities();
                }

                ToDo  = new ObservableCollection <ActivityItemViewModel>();
                Doing = new ObservableCollection <ActivityItemViewModel>();
                Done  = new ObservableCollection <ActivityItemViewModel>();

                foreach (var item in result)
                {
                    switch ((ActivityState)item.State)
                    {
                    case Enumerations.ActivityState.ToDo:
                        ToDo.Add(ViewModelHelper.Get(item));
                        break;

                    case Enumerations.ActivityState.Doing:
                        Doing.Add(ViewModelHelper.Get(item));
                        break;

                    case Enumerations.ActivityState.Done:
                        Done.Add(ViewModelHelper.Get(item));
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                _dialogsService.ShowMessage("Error", "Ha ocurrido un error inesperado");
            }
            finally
            {
                _dialogsService.HideLoading();
            }
        }
        private async Task Create()
        {
            try
            {
                _dialogsService.ShowDialog();

                var result = await _apiService.CreatePlace(new Models.PlaceModel()
                {
                    Name        = this.Name,
                    Description = this.Description,
                    Longitude   = this.Longitude,
                    Latitude    = this.Latitude
                });

                if (result.HttpResponse.IsSuccessStatusCode)
                {
                    await _dialogsService.ShowMessage(AppResources.ApplicationName,
                                                      "Nuevo lugar guardado");

                    await _navigationService.GoBackAsync();
                }
                else
                {
                    await _dialogsService.ShowMessage(AppResources.ApplicationName,
                                                      "Ha ocurrido un error inesperado.");
                }
            }
            catch (Exception)
            {
                await _dialogsService.ShowMessage(AppResources.ApplicationName,
                                                  "Ha ocurrido un error inesperado. Verifique su conexion a internet.");
            }
            finally
            {
                _dialogsService.HideDialog();
            }
        }
 private async Task Save()
 {
     try
     {
         _dialogsService.ShowLoading();
         if (_context.UseCloud)
         {
             await SaveInCloud();
         }
         else
         {
             await SaveInLocalDatabase();
         }
     }
     catch (Exception)
     {
         _dialogsService.ShowMessage("Error", "Ha ocurrido un error, revise su conexión.");
     }
     finally
     {
         _dialogsService.HideLoading();
     }
 }