/// <summary> /// Save the evaluation and add signature if needed and if asked /// </summary> /// <param name="signature">Boolean, true if the user has clicked on sign button</param> async void SaveEvaluation(Boolean signature) { if (signature && Eval.Criterias.All(c => !c.SelectedLevel.Equals("")) && !Eval.IsSigned) { ComeBackSigning = true; await Navigation.PushAsync(new SigningPage(Eval, CurrentCandidate)); } Eval.LastUpdatedDate = DateTime.Now; String jsonEval = JsonParser.GenerateJsonEval(Eval); JsonParser.WriteJsonInInternalMemory(jsonEval, CurrentCandidate.Id, LoggedUser.Id, CurrentEvent.Id); foreach (Criteria c in Eval.Criterias) { c.IsModified = false; } Eval.IsModified = false; int index = CandidateList.IndexOf(CandidateList.Where(x => x.Id == CurrentCandidate.Id).First()); CandidateList[index] = CurrentCandidate; CurrentCandidate.CheckStatus(); ChangeStatusImage(); if (Eval.Criterias.All(c => !c.SelectedLevel.Equals(""))) { ButtonSigner.IsEnabled = true; } else { ButtonSigner.IsEnabled = false; } await Task.Run(() => { Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = false; }); EvaluationSender.AddEvaluationInQueue(jsonEval); EvaluationSender.SendJsonEvalToServer(); Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = true; }); }); }
/// <summary> /// Executed when window is displayed /// </summary> protected override void OnAppearing() { //Add the footer to the list view AddFooter(); base.OnAppearing(); Title = CurrentEvent.Name; MyListView.ItemsSource = Items; CurrentCandidate.CheckStatus(); ChangeStatusImage(); if (Eval.IsModified) { GoToPageNote = false; } if (!CurrentEvent.SigningNeeded) { ButtonSigner.IsVisible = false; } if (Eval.Criterias.All(c => !c.SelectedLevel.Equals(""))) { ButtonSigner.IsEnabled = true; } else { ButtonSigner.IsEnabled = false; } GoToPageNote = false; if (ComeBackSigning && Eval.IsSigned) { SaveEvaluation(false); ComeBackSigning = false; } }