/// <summary>
        /// The remove task.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        private void RemoveTask(IUserTaskChanged sender, UserTaskModel task)
        {
            if (this.userTaskManager.Tasks.Contains(task))
            {
                this.userTaskManager.Tasks.Remove(task);
            }

            sender.UpdateTasks();
        }
        /// <summary>
        /// The add task.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        private void AddTask(IUserTaskChanged sender, UserTaskModel task)
        {
            if (!this.userTaskManager.Tasks.Contains(task))
            {
                this.userTaskManager.Tasks.Add(task);
            }

            this.taskClients.ToList().ForEach(client => client.UpdateTasks());
        }
        /// <summary>
        /// The remove client.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        public void RemoveClient(IUserTaskChanged client)
        {
            if (!this.taskClients.Contains(client))
            {
                return;
            }

            this.taskClients.Remove(client);

            client.TaskAdded   -= this.AddTask;
            client.TaskRemoved -= this.RemoveTask;
        }
        /// <summary>
        /// The add client.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        public void AddClient(IUserTaskChanged client)
        {
            if (this.taskClients == null)
            {
                this.taskClients = new ObservableCollection <IUserTaskChanged>();
            }

            if (this.taskClients.Contains(client))
            {
                return;
            }

            this.taskClients.Add(client);

            client.TaskAdded   += this.AddTask;
            client.TaskRemoved += this.RemoveTask;
        }
Example #5
0
 /// <summary>
 /// The on task removed.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="task">
 /// The task.
 /// </param>
 protected virtual void OnTaskRemoved(IUserTaskChanged sender, UserTaskModel task)
 {
     this.TaskRemoved?.Invoke(sender, task);
 }