Esempio n. 1
0
        public async void UpdateFormsList()
        {
            ActivityIndicator = true;
            Forms             = new ObservableCollection <FormDetailViewModel>();
            try {
                var formsList = await _formService.GetFormsAsync();

                foreach (Form _form in formsList)
                {
                    var formViewModel = new FormDetailViewModel(new PageService())
                    {
                        Id                      = _form.Id,
                        RemoteId                = _form.RemoteId,
                        Title                   = _form.Title,
                        DiscursiveQuestions     = _form.DiscursiveQuestions,
                        MultipleChoiceQuestions = _form.MultipleChoiceQuestions
                    };
                    ActivityIndicator = false;
                    formViewModel.SplitMultipleChoiceQuestions();
                    Forms.Add(formViewModel);
                }

                if (formsList.Count == 0)
                {
                    ActivityIndicator = false;
                    FormVisibility    = false;
                    NoFormWarning     = true;
                }
                else
                {
                    ActivityIndicator = false;
                    FormVisibility    = true;
                    NoFormWarning     = false;
                }
            }
            catch (Exception ex) {
                ActivityIndicator = false;
                Debug.WriteLine("[Update forms list] " + ex.Message + "\n" + ex.StackTrace);
                await _pageService.DisplayAlert("Falha ao carregar formulários",
                                                "Houve um erro ao estabelecer conexão com o servidor. Por favor, tente novamente.",
                                                null, "OK");

                await _pageService.PopAsync();
            }
        }
Esempio n. 2
0
        public async Task <Form> SelectNextForm()
        {
            var listForm = await _formService.GetFormsAsync();

            return(GetLatestForm(listForm));
        }