Exemplo n.º 1
0
        /// <summary>
        /// Adds a new subtask to the collection.
        /// </summary>
        private async Task AddSubtask()
        {
            // New Subtask
            SubtaskViewModel subtask = new SubtaskViewModel()
            {
                Name = this.NewSubtaskName
            };

            // Subscribe to property changed event for new subtask
            subtask.PropertyChanged += SubtaskViewModel_PropertyChanged;

            // Add subtask to database
            await _repo.AddSubtask(subtask, this.Id).ContinueWith(async p =>
            {
                subtask.Id         = await p;
                subtask.TodoTaskId = this.Id;
            });

            // Add item to view
            Subtasks.Add(subtask);

            subtask.IsCompleted = false;

            // Reset new subtask
            NewSubtaskName  = null;
            NewSubtaskAdded = true;
            NewSubtaskAdded = false;
        }