public void OnNavigatedTo(INavigationParameters parameters)
 {
     if (parameters.GetNavigationMode() == NavigationMode.New)
     {
         MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
         var fooTasks = fooMyTaskRepository.GetMyTask();
         foreach (var item in fooTasks)
         {
             MyTaskItemList.Add(new MyTaskItem
             {
                 MyTaskName   = item.MyTaskName,
                 MyTaskDate   = item.MyTaskDate,
                 MyTaskStatus = item.MyTaskStatus,
             });
         }
     }
     else
     {
         if (parameters.ContainsKey("Mode"))
         {
             string TaskMode  = parameters.GetValue <string>("Mode");
             var    fooObject = parameters.GetValue <MyTaskItem>("MyTaskItem");
             var    index     = MyTaskItemList.IndexOf(MyTaskItemList.FirstOrDefault(x => x.MyTaskName == fooObject.MyTaskName));
             if (TaskMode == "Update")
             {
                 MyTaskItemList[index] = fooObject;
             }
             else
             {
                 MyTaskItemList.RemoveAt(index);
             }
         }
     }
 }
        public MainPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            MyTaskRefreshCommand = new DelegateCommand(() =>
            {
                RefreshIndex++;
                MyTaskItemList.Clear();
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = $"{RefreshIndex} {item.MyTaskName}",
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
                RefreshingStatus = false;
            });

            MyTaskItemSelectedCommand = new DelegateCommand(async() =>
            {
                var fooPara = new NavigationParameters();
                fooPara.Add("Record", MyTaskItemSelected.Clone());
                await _navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });
        }
        public MainPageViewModel(INavigationService navigationService, IPageDialogService dialogService)
        {
            this.navigationService    = navigationService;
            this.dialogService        = dialogService;
            MyTaskItemSelectedCommand = new DelegateCommand(async() =>
            {
                //await _dialogService.DisplayAlertAsync("Info", $"你選取的是 {MyTaskItemSelected.MyTaskName}", "OK");

                NavigationParameters fooPara = new NavigationParameters();
                fooPara.Add("MyTaskItem", MyTaskItemSelected.Clone());
                fooPara.Add("Mode", "Edit");
                await navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });

            MyTaskRefreshCommand = new DelegateCommand(() =>
            {
                RefreshIndex++;
                MyTaskItemList.Clear();
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = $"{RefreshIndex} {item.MyTaskName}",
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
                RefreshingStatus = false;
            });
        }
Beispiel #4
0
        public void AddTaskShouldFail()
        {
            var my_task    = MyTaskFactory.Instance.CreateTask("test_description", DateTime.Today, "test_project", "test_owner", "test_asignee", MyTask.Convert("InProgress"), "test_review");
            var repository = new MyTaskRepository();

            repository.AddTask(my_task);

            Assert.That(() => repository.AddTask(my_task), Throws.TypeOf <DuplicateWaitObjectException>());
        }
Beispiel #5
0
        public void OnNavigatedTo(NavigationParameters parameters)
        {
            if (parameters.ContainsKey("Action"))
            {
                string action = parameters["Action"] as string;
                var    fooObj = parameters["ActionRec"] as MyTaskItem;

                switch (action)
                {
                case "D":
                    var bar = MyTaskItemList.FirstOrDefault(x => x.MyTaskName == fooObj.MyTaskName);
                    if (bar != null)
                    {
                        MyTaskItemList.Remove(bar);
                    }
                    break;

                case "S":
                    var barS = MyTaskItemList.FirstOrDefault(x => x.MyTaskName == fooObj.MyTaskName);
                    if (barS != null)
                    {
                        barS.MyTaskName   = fooObj.MyTaskName;
                        barS.MyTaskStatus = fooObj.MyTaskStatus;
                        barS.MyTaskDate   = fooObj.MyTaskDate;
                    }
                    break;

                case "A":
                    MyTaskItemList.Insert(0, fooObj);
                    break;

                default:
                    break;
                }
            }
            if (MyTaskItemList.Count == 0)
            {
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = item.MyTaskName,
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
            }
        }
Beispiel #6
0
        public void OnNavigatedTo(NavigationParameters parameters)
        {
            MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
            var fooTasks = fooMyTaskRepository.GetMyTask();

            foreach (var item in fooTasks)
            {
                MyTaskItemList.Add(new MyTaskItem
                {
                    MyTaskName   = item.MyTaskName,
                    MyTaskDate   = item.MyTaskDate,
                    MyTaskStatus = item.MyTaskStatus,
                });
            }
        }
        public MainPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            MyTaskRefreshCommand = new DelegateCommand(() =>
            {
                RefreshIndex++;
                MyTaskItemList.Clear();
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = $"{RefreshIndex} {item.MyTaskName}",
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
                RefreshingStatus = false;
            });

            MyTaskItemSelectedCommand = new DelegateCommand(async() =>
            {
                var fooPara = new NavigationParameters();
                fooPara.Add("Record", MyTaskItemSelected.Clone());
                fooPara.Add("Action", "S");
                await _navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });
            AddCommand = new DelegateCommand(async() =>
            {
                var fooPara = new NavigationParameters();
                fooPara.Add("Record", new MyTaskItem()
                {
                    MyTaskName = "請輸入工作名稱"
                });
                fooPara.Add("Action", "A");
                await _navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });
            DeleteCommand = new DelegateCommand <MyTaskItem>(x =>
            {
                var fooEditTask = MyTaskItemList.FirstOrDefault(s => s.MyTaskName == x.MyTaskName);
                if (fooEditTask != null)
                {
                    MyTaskItemList.Remove(fooEditTask);
                }
            });
        }
Beispiel #8
0
        public void EventSpyShouldWork()
        {
            var logMock    = new Moq.Mock <IEventLogger>();
            var my_task    = MyTaskFactory.Instance.CreateTask("test_description", DateTime.Today, "test_project", "test_owner", "test_asignee", MyTask.Convert("InProgress"), "test_review", logMock.Object);
            var repository = new MyTaskRepository();

            repository.AddTask(my_task);

            repository.UpdateTask("AssignTask", my_task, "Bianca");
            repository.UpdateTask("ChangeStatus", my_task, "Done");
            repository.UpdateTask("GiveReview", my_task, "Very well");

            logMock.Verify(_ => _.Log("Project : test_project Task : test_description was assigned to : Bianca"), Times.Once);
            logMock.Verify(_ => _.Log("Project : test_project Task : test_description status has changed to : Done"), Times.Once);
            logMock.Verify(_ => _.Log("Project : test_project Task : test_description has received a review : Very well"), Times.Once);
        }
 public void OnNavigatedTo(INavigationParameters parameters)
 {
     if (parameters.GetNavigationMode() == NavigationMode.New)
     {
         MyTaskRepository repository = new MyTaskRepository();
         var tasks = repository.GetMyTask();
         foreach (var item in tasks)
         {
             MyTaskItemList.Add(item);
         }
     }
     else
     {
         if (parameters.ContainsKey("Mode"))
         {
             var        Mode = parameters.GetValue <string>("Mode");
             MyTaskItem item = parameters
                               .GetValue <MyTaskItem>("MyTaskSelectedItem");
             if (Mode == "修改")
             {
                 MyTaskItem UpdateRecore =
                     MyTaskItemList
                     .FirstOrDefault(x => x.MyTaskName == item.MyTaskName);
                 if (UpdateRecore != null)
                 {
                     UpdateRecore.MyTaskDate   = item.MyTaskDate;
                     UpdateRecore.MyTaskStatus = item.MyTaskStatus;
                 }
             }
             if (Mode == "刪除")
             {
                 MyTaskItem DeleteRecore =
                     MyTaskItemList
                     .FirstOrDefault(x => x.MyTaskName == item.MyTaskName);
                 if (DeleteRecore != null)
                 {
                     MyTaskItemList.Remove(DeleteRecore);
                 }
             }
             if (Mode == "新增")
             {
                 MyTaskItemList.Insert(0, item);
             }
         }
     }
 }
 public MainPageViewModel(INavigationService navigationService)
 {
     this.navigationService = navigationService;
     ItemSelectedCommand    = new DelegateCommand(() =>
     {
         NavigationParameters para = new NavigationParameters();
         para.Add("MyTaskSelectedItem", MyTaskSelectedItem.Clone());
         navigationService.NavigateAsync("DetailPage", para);
     });
     RefreshCommand = new DelegateCommand(() =>
     {
         IsRefreshing = true;
         MyTaskRepository repository = new MyTaskRepository();
         var tasks = repository.GetMyTask();
         foreach (var item in tasks)
         {
             MyTaskItemList.Add(item);
         }
         IsRefreshing = false;
     });
     AddCommand = new DelegateCommand(OnAddCommand);
 }
        public MainPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            MyTaskRefreshCommand = new DelegateCommand(() =>
            {
                RefreshIndex++;
                MyTaskItemList.Clear();
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = $"{RefreshIndex} {item.MyTaskName}",
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
                RefreshingStatus = false;
            });
        }
Beispiel #12
0
        public MainPageViewModel(IPageDialogService dialogService, INavigationService navigationService,
                                 IEventAggregator eventAggregator)
        {
            _eventAggregator   = eventAggregator;
            _navigationService = navigationService;
            _dialogService     = dialogService;

            MyTaskItemSelectedCommand = new DelegateCommand(async() =>
            {
                //await _dialogService.DisplayAlertAsync("Info", $"你選取的是 {MyTaskItemSelected.MyTaskName}", "OK");

                NavigationParameters fooPara = new NavigationParameters();

                // 為什麼這裡需要做 MemberwiseClone,不做,會有甚麼影響
                fooPara.Add("MyTaskItem", MyTaskItemSelected.Clone() as MyTaskItem);
                fooPara.Add("Mode", "Edit");
                await _navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });

            AddCommand = new DelegateCommand(async() =>
            {
                NavigationParameters fooPara = new NavigationParameters();
                fooPara.Add("Mode", "Add");
                await _navigationService.NavigateAsync("TaskDetailPage", fooPara);
            });

            MyTaskRefreshCommand = new DelegateCommand(() =>
            {
                RefreshIndex++;
                MyTaskItemList.Clear();
                MyTaskRepository fooMyTaskRepository = new MyTaskRepository();
                var fooTasks = fooMyTaskRepository.GetMyTask();
                foreach (var item in fooTasks)
                {
                    MyTaskItemList.Add(new MyTaskItem
                    {
                        MyTaskName   = $"{RefreshIndex} {item.MyTaskName}",
                        MyTaskDate   = item.MyTaskDate,
                        MyTaskStatus = item.MyTaskStatus,
                    });
                }
                RefreshingStatus = false;
            });

            _eventAggregator.GetEvent <MyTaskItemEvent>().Subscribe(x =>
            {
                var fooEditTask = MyTaskItemList.FirstOrDefault(s => s.MyTaskName == x.MyTaskItemSelected.MyTaskName);
                if (x.TaskMode == "Edit")
                {
                    if (fooEditTask != null)
                    {
                        fooEditTask.MyTaskDate   = x.MyTaskItemSelected.MyTaskDate;
                        fooEditTask.MyTaskStatus = x.MyTaskItemSelected.MyTaskStatus;
                    }
                }
                else if (x.TaskMode == "Delete")
                {
                    if (fooEditTask != null)
                    {
                        MyTaskItemList.Remove(fooEditTask);
                    }
                }
                else
                {
                    MyTaskItemList.Insert(0, x.MyTaskItemSelected);
                }
            });
        }
Beispiel #13
0
 public TaskManager(MyTaskRepository repository)
 {
     this.repository = repository;
 }