Beispiel #1
0
 public void EditSelectedTask()
 {
     EditTask = new UiModel.Task();
     Mapper.Map(SelectedTask, EditTask);
     IsEditPopupOpen  = true;
     PopupGridVisible = Visibility.Visible;
 }
Beispiel #2
0
 public void UpdateTask()
 {
     EditTask.isDirty = true;
     if (EditTask.SelfValidate().IsValid)
     {
         UiModel.Task task = RawTasks.FirstOrDefault(t => t.Id == EditTask.Id);
         if (EditTask.Status == Status.Completed)
         {
             EditTask.CompletedDate = DateTime.Now;
         }
         else
         {
             EditTask.CompletedDate = null;
         }
         Mapper.Map(EditTask, task);
         eventAggregator.PublishOnCurrentThread(SelectedTask);
         eventAggregator.PublishOnCurrentThread(new KeyValuePair <TaskState, UiModel.Task>(TaskState.Update, EditTask));
         Navigate(0, RawTasks);
         IsEditPopupOpen  = false;
         PopupGridVisible = Visibility.Collapsed;
     }
     else
     {
         EditTask.Refresh();
     }
 }
Beispiel #3
0
        public void DropTask(DragEventArgs e)
        {
            string name = ((DependencyObject)e.Source).GetValue(FrameworkElement.NameProperty) as string;

            if (e.Data.GetDataPresent(Helper.Constants.SelectedTask))
            {
                UiModel.Task task = e.Data.GetData(Helper.Constants.SelectedTask) as UiModel.Task;
                DragAndDrop(name, task);
            }
        }
Beispiel #4
0
        public void EditTask(UiModel.Task task)
        {
            switch (task.Status)
            {
            case Status.New:
                UiModel.Task newTask = NewTasks.FirstOrDefault(t => t.Id == task.Id);
                if (newTask != null)
                {
                    Mapper.Map(task, newTask);
                }
                else
                {
                    DeleteFromList(RawTask);
                    task.CompletedDate = null;
                    NewTasks.Add(task);
                }
                break;

            case Status.InProgress:
                UiModel.Task inProgressTask = TasksInProgress.FirstOrDefault(t => t.Id == task.Id);
                if (inProgressTask != null)
                {
                    Mapper.Map(task, inProgressTask);
                }
                else
                {
                    DeleteFromList(RawTask);
                    task.CompletedDate = null;
                    TasksInProgress.Add(task);
                }
                break;

            case Status.Completed:
                UiModel.Task completedTask = TasksCompleted.FirstOrDefault(t => t.Id == task.Id);
                if (completedTask != null)
                {
                    Mapper.Map(task, completedTask);
                }
                else
                {
                    DeleteFromList(RawTask);
                    task.CompletedDate = DateTime.Now;
                    TasksCompleted.Add(task);
                }
                break;
            }
        }
Beispiel #5
0
        public void DeleteFromList(UiModel.Task task)
        {
            switch (task.Status)
            {
            case Status.New:
                NewTasks.Remove(NewTasks.FirstOrDefault(t => t.Id == task.Id));
                break;

            case Status.InProgress:
                TasksInProgress.Remove(TasksInProgress.FirstOrDefault(t => t.Id == task.Id));
                break;

            case Status.Completed:
                TasksCompleted.Remove(TasksCompleted.FirstOrDefault(t => t.Id == task.Id));
                break;
            }
        }
Beispiel #6
0
        public void CreateTask(UiModel.Task task)
        {
            task.Id            = GetId();
            task.CompletedDate = null;
            switch (task.Status)
            {
            case Status.New:
                NewTasks.Add(task);
                break;

            case Status.InProgress:
                TasksInProgress.Add(task);
                break;

            case Status.Completed:
                task.CompletedDate = DateTime.Now;
                TasksCompleted.Add(task);
                break;
            }
        }
Beispiel #7
0
        public void DragAndDrop(String name, UiModel.Task task)
        {
            switch (name)
            {
            case nameof(NewTasks):
                if (task.Status != Status.New)
                {
                    DeleteFromList(task);
                    task.Status        = Status.New;
                    task.CompletedDate = null;
                    NewTasks.Add(task);
                    TaskService.Update(Mapper.Map <DataModel.Task>(task));
                }
                break;

            case nameof(TasksInProgress):
                if (task.Status != Status.InProgress)
                {
                    DeleteFromList(task);
                    task.CompletedDate = null;
                    task.Status        = Status.InProgress;
                    TasksInProgress.Add(task);
                    TaskService.Update(Mapper.Map <DataModel.Task>(task));
                }
                break;

            case nameof(TasksCompleted):
                if (task.Status != Status.Completed)
                {
                    DeleteFromList(task);
                    task.CompletedDate = DateTime.Now;
                    task.Status        = Status.Completed;
                    TasksCompleted.Add(task);
                    TaskService.Update(Mapper.Map <DataModel.Task>(task));
                }
                break;
            }
        }
Beispiel #8
0
 public void Handle(UiModel.Task message)
 {
     RawTask = message;
 }
Beispiel #9
0
 public void SetEditTask()
 {
     RawTask = SelectedTask;
     eventAggregator.BeginPublishOnUIThread(RawTask);
 }