public void UpdateTask(TaskViewModel task) { this.InvokeIfRequired(() => { if (tasks != null) { var found = this.tasks.Where(x => x.Id == task.Id).FirstOrDefault(); if (found != null) { int index = this.tasks.IndexOf(found); this.tasks[index] = task; this.taskViewModelBindingSource.ResetBindings(false); } } }); }
public void AddTask(TaskViewModel task) { this.InvokeIfRequired(() => { if (tasks != null) { this.tasks.Add(task); this.taskViewModelBindingSource.ResetBindings(false); } }); }
private TaskViewModel Convert(Task task) { TaskViewModel viewModel = new TaskViewModel(); viewModel.Id = task.Id; viewModel.Name = task.Name; viewModel.OrderId = task.OrderId; switch (task.Type) { case TaskType.DAYS: viewModel.Type = ViewModelTypeDay; break; case TaskType.DAYS_NIGHT: viewModel.Type = ViewModelTypeDayAndNight; break; default: break; } viewModel.Category = TaskCategoryConsts.ToString(task.Category); return viewModel; }