Beispiel #1
0
        public void SetLatestFormFields(Form latestForm)
        {
            if (latestForm == null)
            {
                FormVisibility = false;
                NoFormWarning  = true;
                Debug.WriteLine("[SelectForm]: noFormWarning is set to: " + _noFormWarning);
                return;
            }
            else
            {
                FormVisibility = true;
                NoFormWarning  = false;

                FormTitle = latestForm.Title;
                int size = latestForm.MultipleChoiceQuestions.Count + latestForm.DiscursiveQuestions.Count;
                FormQuestions = (size).ToString() + " Questões";
            }

            Debug.WriteLine("[SelectForm]: gets a non null forum");
            Debug.WriteLine("[SelectForm]: title: " + FormTitle);
            Debug.WriteLine("[SelectForm]: questions: " + FormQuestions);


            SelectedForm = new FormDetailViewModel(_pageService)
            {
                Title = latestForm.Title,
                MultipleChoiceQuestions = latestForm.MultipleChoiceQuestions,
                DiscursiveQuestions     = latestForm.DiscursiveQuestions
            };

            IsLoaded = true;

            Debug.WriteLine("[SelectNextForm]: title " + SelectedForm.Title);
        }
Beispiel #2
0
 public async Task SelectForm(FormDetailViewModel form)
 {
     if (form == null)
     {
         return;
     }
     SelectedForm = form;
     await _pageService.PushAsync(new Views.Forms.FormDetailPage(SelectedForm));
 }
Beispiel #3
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();
            }
        }