private async void UpdateComment(object obj) { if (!ScanSuccess || string.IsNullOrEmpty(lastScan)) { await Application.Current.MainPage.DisplayAlert("Failed", "Last scan was not successfull. Try to scan the badge again.", "OK"); } AppController.AddBusy(this); // Update the comment. var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("comment", Comment) }); HttpMessage response = await Login.Instance.DoPost($"api/badge-scanning/edit/{ScannedId}", formContent); ScanSuccess = response.Success; if (response.Success) { string json = await response.Response.Content.ReadAsStringAsync(); JSONQRComment commentResult = JsonConvert.DeserializeObject <JSONQRComment>(json); ScanSuccess = commentResult.success; if (!commentResult.success) { ErrorMessage = commentResult.message; } else { ErrorMessage = ""; ScanSuccess = false; } } else { if (string.IsNullOrEmpty(response.Message)) { response.Message = "Could not save comment."; } ErrorMessage = response.Message; } AppController.RemoveBusy(this); }
private async void DoScanResult(ZXing.Result result) { DoScan = false; string scanned_user = result.Text; lastScan = scanned_user; AppController.AddBusy(this); HttpMessage response = await Login.Instance.DoPost($"api/badge-scanning/{scanned_user}"); ScanSuccess = response.Success; if (response.Success) { string json = await response.Response.Content.ReadAsStringAsync(); JSONScanQR scanResult = JsonConvert.DeserializeObject <JSONScanQR>(json); ScanSuccess = scanResult.success; if (!scanResult.success) { ErrorMessage = scanResult.message; } else { ScannedName = scanResult.user_name; scannedId = scanResult.id; } } else { if (string.IsNullOrEmpty(response.Message)) { response.Message = "Could not verify."; } ErrorMessage = response.Message; } AppController.RemoveBusy(this); }
private async void SubmitButtonClicked(object obj) { AppController.AddBusy("SignInViewModel"); IsPasswordEmpty = string.IsNullOrEmpty(Password); if (string.IsNullOrEmpty(Mail) || !mail.Contains("@") || !mail.Contains(".")) { HasError = true; } else if (!isPasswordEmpty) { if (await DoLogin(Mail, Password, true)) { // Save this. Account account = new Account { Username = Mail }; account.Properties.Add("Password", Password); await SecureStorageAccountStore.SaveAsync(account, App.AppName); } } AppController.RemoveBusy("SignInViewModel"); }
private async void SubmitButtonClicked(object obj) { if (!AgreePolicy) { await Application.Current.MainPage.DisplayAlert("Failed", "Please agree to the privacy policy.", "OK"); return; } AppController.AddBusy(this); IsPasswordEmpty = string.IsNullOrEmpty(Password); MailHasError = string.IsNullOrEmpty(Mail) || !mail.Contains("@") || !mail.Contains("."); ConfirmPasswordError = string.IsNullOrEmpty(ConfirmPassword) || !string.Equals(ConfirmPassword, Password); IsFirstNameEmpty = string.IsNullOrEmpty(FirstName); IsSurnameEmpty = string.IsNullOrEmpty(Surname); AssociationError = Association != null && string.IsNullOrEmpty(Association.name); StudyProgrammeError = !ShowCompany && string.IsNullOrEmpty(StudyProgramme); TicketCodeError = string.IsNullOrEmpty(TicketCode); StudyProgrammeOtherError = ShowOtherProgramme && string.IsNullOrEmpty(studyProgrammeOther); CompanyNameError = ShowCompany && string.IsNullOrEmpty(CompanyName); int associationIndex = -1; if (!AssociationError) { for (int i = 0; i < Associations.Count; i++) { if (Associations[i].name.Equals(Association.name)) { associationIndex = i; break; } } if (associationIndex < 0) { AssociationError = true; } } if (!isPasswordEmpty && !MailHasError && !ConfirmPasswordError && !IsFirstNameEmpty && !IsSurnameEmpty && !AssociationError && !StudyProgrammeError && !TicketCodeError && !StudyProgrammeOtherError && !CompanyNameError) { // TODO: set TicketCodeError to false if it doesn't work and we get a false. HttpMessage httpMessage = await Login.Instance.DoRegisterAsync(new Model.RegisterModel { code = TicketCode, firstname = FirstName, surname = Surname, vereniging = associationIndex, bus = UseBus, programme = StudyProgramme, programmeOther = StudyProgrammeOther, companyName = CompanyName, vegetarian = Vegetarian, specialNeeds = OtherRemarks, email = Mail, password = Password, confirm = ConfirmPassword, privacyPolicyAgree = AgreePolicy, subscribe = MailSubscribe }); AppController.RemoveBusy(this); if (httpMessage.Success) { await Application.Current.MainPage.DisplayAlert("Success", "You are logged in.", "OK"); } else { await Application.Current.MainPage.DisplayAlert("Failed", httpMessage.Message, "OK"); } } AppController.RemoveBusy(this); }