private async Task ConfirmEmailAsync(string userId, string s) { try { if (string.IsNullOrWhiteSpace(s)) { _dialogHelper.ShowError(Activity, "The code cannot be empty."); return; } if (!Regex.IsMatch(s, "[0-9]{4,}")) { _dialogHelper.ShowError(Activity, "The code entered is incorrect."); return; } _progressBarHelper.Show(); var res = await _authHelper.ConfirmEmailAsync(new ConfirmationRequestDto { Code = s, UserId = userId }); _progressBarHelper.Hide(); if (res.StatusCode == HttpStatusCode.OK) { Dismiss(); var activity = Activity; _dialogHelper.ShowSuccessDialog(Activity, "Signing Up was successful. Please Sign In" , (o, ea) => { activity.StartActivity(typeof(SignInActivity)); activity.Finish(); }); } else if (res.StatusCode == HttpStatusCode.BadRequest) { _dialogHelper.ShowError(Activity, "The code entered is incorrect."); } else { _dialogHelper.ShowError(Activity); } } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(Activity, ex); } }
private async void SaveButton_Click(object sender, EventArgs e) { try { if (!ValidateInputs()) { return; } _progressBarHelper.Show(); var task = new ScheduledTask() { Id = Guid.NewGuid(), Title = titleEditText.Text, Start = _startDate == default || _startTime == default ? DateTime.MinValue : Utilities.ToDateTime(_startDate, _startTime), End = _endDate == default || _endTime == default ? DateTime.MinValue : Utilities.ToDateTime(_endDate, _endTime), Importance = SelectedImportance, Note = noteEditText.Text, Repeat = (Frequency)_selectedRepeatIndex, ApplicationUserId = Utilities.GetUserId(), ClientUpdatedOnTicks = DateTime.UtcNow.Ticks }; await _taskDataHelper.InsertAsync(task); if (task.Start > DateTime.Now) { _alarmHelper.SetAlarm(task); } _ = SyncService.Instance.SyncAsync(); // warning suppressed on purpose StartActivity(typeof(TasksActivity)); _progressBarHelper.Hide(); FinishAffinity(); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
private async void ResetButton_Click(object sender, EventArgs e) { try { if (!ValidateInputs()) { return; } _progressBarHelper.Show(); var dto = new ResetPasswordRequestDto() { Code = codeEditText.Text, Password = passwordEditText.Text, Email = _email }; var res = await _authHelper.ResetPasswordAsync(dto); _progressBarHelper.Hide(); if (res.StatusCode == HttpStatusCode.OK) { _dialogHelper.ShowSuccessDialog(this, "Resetting Password was successful. Please Sign In" , (o, ea) => { StartActivity(typeof(SignInActivity)); Finish(); }); } else if (res.StatusCode == HttpStatusCode.BadRequest) { _dialogHelper.ShowError(this, "The code entered is incorrect."); } else { _dialogHelper.ShowError(this); } } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
private async Task SendPasswordResetEmailAsync(string s) { try { if (string.IsNullOrWhiteSpace(s) || !CoreHelper.Utilities.IsValidEmail(s)) { _dialogHelper.ShowError(this, "Email entered is not valid."); return; } frag.ShowProgressBar(); var res = await _authHelper.SendPasswordResetEmailAsync(new SendPasswordResetEmailDto() { Email = s }); frag.HideProgressBar(); if (res.StatusCode == HttpStatusCode.OK || res.StatusCode == HttpStatusCode.BadRequest) { frag.Dismiss(); _dialogHelper.ShowSuccessDialog(this, "Email Sent." , (o, ea) => { var intent = new Intent(this, typeof(ResetPasswordActivity)); intent.PutExtra("Email", s); StartActivity(intent); }); } else { _dialogHelper.ShowError(this); } } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
private async void SaveButton_Click(object sender, EventArgs e) { try { if (!ValidateInputs()) { return; } _progressBarHelper.Show(); _scheduledTask.Title = titleEditText.Text; _scheduledTask.Start = _startDate == default || _startTime == default ? _scheduledTask.Start : Utilities.ToDateTime(_startDate, _startTime); _scheduledTask.End = _endDate == default || _endTime == default ? _scheduledTask.End : Utilities.ToDateTime(_endDate, _endTime); _scheduledTask.Importance = SelectedImportance; _scheduledTask.Note = noteEditText.Text; _scheduledTask.Repeat = (Frequency)_selectedRepeatIndex; _scheduledTask.ClientUpdatedOnTicks = DateTime.UtcNow.Ticks; await _taskDataHelper.UpdateAsync(_scheduledTask); UpdateAlarm(); _ = SyncService.Instance.SyncAsync(); // warning suppressed on purpose StartActivity(typeof(TasksActivity)); _progressBarHelper.Hide(); FinishAffinity(); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
private async void SignUpButton_Click(object sender, EventArgs e) { try { if (!ValidateInputs()) { return; } var dto = new CreateAccountDto() { Username = usernameEditText.Text.Trim(), Email = emailEditText.Text.Trim(), Password = passwordEditText.Text }; _progressBarHelper.Show(); var result = await _authHelper.SignUpAsync(dto); _progressBarHelper.Hide(); if (result.Succeeded) { ShowConfirmationCodeDialog(result.UserId); return; } HandleError(result.ErrorType); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
private async void Adapter_ItemDeleteClick(object sender, ScheduledTask e) { try { _progressBarHelper.Show(); ToggleEmptyView(); await _taskDataHelper.MarkAsDeletedAsync(e.Id); _alarmHelper.CancelAlarm(e); _ = SyncService.Instance.SyncAsync() .ContinueWith(async t => { try { await _taskDataHelper.DeleteAsync(e.Id); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); } } , TaskContinuationOptions.OnlyOnRanToCompletion); // warning suppressed on purpose _progressBarHelper.Hide(); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); _progressBarHelper.Hide(); _dialogHelper.ShowError(this, ex); } }
public void HideProgressBar() { _progressBarHelper.Hide(); }