Example #1
0
        private async Task LoadTasks()
        {
            var result = await apiService.GetAllTasks();

            if (result.HttpResponse.IsSuccessStatusCode)
            {
                foreach (var item in result.Data)
                {
                    switch (item.Status)
                    {
                    case 0:
                        ToDo.Add(ViewModelHelper.Get(item));
                        break;

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

                    case 2:
                        Done.Add(ViewModelHelper.Get(item));
                        break;
                    }
                }
            }
        }
        private async Task SaveInCloud()
        {
            if (ActionMode == ActionMode.Create)
            {
                var result = await _apiService.CreateActivity(ViewModelHelper.Get(SelectedActivity));

                if (result.Response.IsSuccessStatusCode)
                {
                    _dialogsService.ShowMessage("Exito", "Actividad creada.");
                    await NavigationService.GoBackAsync();
                }
                else
                {
                    _dialogsService.ShowMessage("Error", "Ha ocurrido un error, revise su conexión.");
                }
            }
            else if (ActionMode == ActionMode.Edit)
            {
                var result = await _apiService.UpdateActivity(ViewModelHelper.Get(SelectedActivity));

                if (result.Response.IsSuccessStatusCode)
                {
                    _dialogsService.ShowMessage("Exito", "Actividad actualizada.");
                    await NavigationService.GoBackAsync();
                }
                else
                {
                    _dialogsService.ShowMessage("Error", "Ha ocurrido un error, revise su conexión.");
                }
            }
        }
Example #3
0
        private async Task ChangeStatus()
        {
            List <string> options = new List <string>();

            switch (Status)
            {
            case Statuses.ToDo:
                options.Add("Doing");
                options.Add("Done");
                break;

            case Statuses.Doing:
                options.Add("To Do");
                options.Add("Done");
                break;

            case Statuses.Done:
                options.Add("To Do");
                options.Add("Doing");
                break;
            }

            var selectedOption = await dialogService.ShowOptions("Seleccione el nuevo estado", options);

            switch (selectedOption)
            {
            case "To Do":
                this.Status = Statuses.ToDo;
                break;

            case "Doing":
                this.Status = Statuses.Doing;
                break;

            case "Done":
                this.Status = Statuses.Done;
                break;
            }

            var result = await apiService.Update(ViewModelHelper.Get(this));

            var data = await result.HttpResponse.Content.ReadAsStringAsync();

            if (result.HttpResponse.IsSuccessStatusCode)
            {
                await App.Locator.MainPage.RefreshTasks();
            }
            else
            {
                dialogService.ShowMessage("An error has ocurred");
            }
        }
Example #4
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 SaveInLocalDatabase()
        {
            if (ActionMode == ActionMode.Create)
            {
                SelectedActivity.Id = Guid.NewGuid().ToString();
                await _localDatabaseService.CreateActivity(ViewModelHelper.Get(SelectedActivity));

                _dialogsService.ShowMessage("Exito", "Actividad creada.");
                await NavigationService.GoBackAsync();
            }
            else if (ActionMode == ActionMode.Edit)
            {
                await _localDatabaseService.UpdateActivity(ViewModelHelper.Get(SelectedActivity));

                _dialogsService.ShowMessage("Exito", "Actividad actualizada.");
                await NavigationService.GoBackAsync();
            }
        }