Beispiel #1
0
        public async void AddWorkingTime()
        {
            var selectedDate = MainWindowViewModel.Instance.Contents.OfType <WorkUnitRecorderViewModel>().First().TargetDateTime.Value.Date;

            var now = SystemClockServiceLocator.Current.Now;
            var workingTimeRange = WorkingTimeRange.ForEdit(Dto.TaskId, now, now);

            if (now.Date == selectedDate)
            {
                // もう少しお行儀のいい書き方はないものか...
                var usecase  = new GetWorkingTimeForTimelineUseCase(ContainerHelper.Resolver.Resolve <IWorkingTimeQueryService>());
                var list     = usecase.SelectByYmd(selectedDate.ToYmd());
                var lastTime = list.Where(i => i.TimePeriod.IsFuture == false)
                               .Where(i => i.TimePeriod.IsStopped)
                               .OrderBy(i => i.TimePeriod.EndDateTime.Value)
                               .LastOrDefault();
                if (lastTime != null)
                {
                    workingTimeRange = WorkingTimeRange.ForEdit(Dto.TaskId, lastTime.TimePeriod.EndDateTime.Value.AddMinutes(1), null);
                }
            }
            else
            {
                workingTimeRange = WorkingTimeRange.ForEdit(Dto.TaskId, selectedDate, selectedDate);
            }

            var editDialogVm = new WorkingTimeRangeEditDialogViewModel(workingTimeRange);

            var view = new WorkingTimeRangeEditDialog
            {
                DataContext = editDialogVm
            };

            //show the dialog
            var result = (bool?)await DialogHost.Show(view);

            if (result.HasValue && result.Value)
            {
                var editObj = editDialogVm.WorkingTimeViewModel.DomainModel;
                _Model.AddWorkingTime(editObj);
            }
        }
        public async void AddWorkingTime()
        {
            var workingTimeRange = WorkingTimeRange.ForEdit(Dto.TaskId);

            var editDialogVm = new WorkingTimeRangeEditDialogViewModel(workingTimeRange);

            var view = new WorkingTimeRangeEditDialog
            {
                DataContext = editDialogVm
            };

            //show the dialog
            var result = (bool?)await DialogHost.Show(view);

            if (result.HasValue && result.Value)
            {
                var editObj = editDialogVm.WorkingTimeViewModel.DomainModel;
                _Model.AddWorkingTime(editObj);
            }
        }