Ejemplo n.º 1
0
        /// <summary>
        ///     Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">
        ///     Data used by the command.  If the command does not require data to be passed, this object can
        ///     be set to null.
        /// </param>
        public async void Execute(object parameter)
        {
            if (!CanExecute(parameter))
            {
                return;
            }
            try
            {
                var task = (Task)parameter;
                if (await Tasks.Instance.DeleteTask(task))
                {
                    _viewModel.Tasks.Remove(task);
                    _viewModel.ActiveTasks.Remove(task);
                    TaskToast.RemoveTaskToast(task.TaskId);
                }

                else
                {
                    await new MessageDialog("Failed to delete task", "Error").ShowAsync();
                }
            }
            catch (Exception e)
            {
                await e.Log();

                await e.Display("Failed to delete task.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Adds the toast.
        /// </summary>
        /// <param name="task">The task.</param>
        private void AddToast(Task task)
        {
            var selectedToastTime = (ToastComboBoxItem)ToastTimeComboBox.SelectedItem;

            if (selectedToastTime != null && selectedToastTime.Value != -1)
            {
                TaskToast.CreateTaskToast(task, selectedToastTime.Value);
            }
        }
Ejemplo n.º 3
0
        /// <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();
            }
        }