/// <summary> /// Handles the OnItemClick event of the ExercisesListView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ItemClickEventArgs" /> instance containing the event data.</param> private async void ExercisesListView_OnItemClick(object sender, ItemClickEventArgs e) { var result = await ViewExerciseContentDialog.ShowAsync(); if (result != ContentDialogResult.Primary) { return; } var selectedExercise = (Exercise)ExercisesListView.SelectedItem; if (selectedExercise == null) { return; } var copyExercise = new Model.Task { Title = selectedExercise.Title, Description = selectedExercise.Description, DueDate = selectedExercise.DueDate, DueTime = selectedExercise.DueTime, Users = new List <User> { Users.Instance.SessionUser }, TaskStatus = Model.Task.Status.Added }; await AddTask(copyExercise, NotificationCheckBox.IsChecked != null && NotificationCheckBox.IsChecked.Value); Users.Instance.Changed = true; }
/// <summary> /// Checks the completion of given task. /// </summary> /// <param name="task">The task.</param> /// <returns></returns> private bool CheckCompletion(Model.Task task) { if (task.TaskStatus != Model.Task.Status.Finished) { return(false); } CompletedTasks++; if (task.CompletedOn != null && task.CompletedOn.Value >= DateTimeOffset.Now.AddDays(-7)) { CompletedTasksThisWeek++; } return(true); }
/// <summary> /// Checks the due date. /// </summary> /// <param name="task">The task.</param> private void CheckDueDate(Model.Task task) { if (task.DueDate == null || task.DueDate.Value.Date < DateTimeOffset.Now.Date) { return; } if (task.DueDate.Value.Date == DateTime.Now.Date) { TasksDueToday++; TasksDueThisWeek++; } else if (task.DueDate.Value <= DateTimeOffset.Now.AddDays(7)) { TasksDueThisWeek++; } }
/// <summary> /// Adds the task. /// </summary> /// <param name="task">The task.</param> /// <param name="createToast"></param> /// <returns></returns> private static async Task AddTask(Model.Task task, bool createToast) { try { var createdTask = await Tasks.Instance.AddTask(task); if (createToast) { TaskToast.CreateTaskToast(createdTask, 1440); } } catch (WebException ex) { await ex.Display("Failed to establish internet connection."); await ex.Log(); } catch (Exception ex) { await ex.Display("Failed to add task."); await ex.Log(); } }