Beispiel #1
0
        public async void Execute(IForecastRegistrationViewModel vm)
        {
            // Initialize datecolumns
            var selectedDate = vm.SelectedDate;
            var prevMonth    = selectedDate.FirstDayOfPreviousMonth();

            _forecastRegistrationDataGenerator.GenerateBaseDataByDate(vm.SelectedDate, vm); // Initializes a "clean" month

            // Get data from last month
            var response = await _forecastService.GetByUserIdAndMonth(_selectedUserHandler.UserId, prevMonth.Month, prevMonth.Year, selectedDate.Month, selectedDate.Year);

            // Merge fetched holidays
            _forecastRegistrationDataGenerator.MergeHolidays(vm, response.Holidays);
            var projectDtos = response
                              .ForecastMonth
                              .ForecastDtos
                              .Where(forecast => forecast.ForecastType.SupportsProjectHours)
                              .SelectMany(forecast => forecast.ForecastProjectHoursDtos)
                              .Select(forecastHoursDto => forecastHoursDto.Project)
                              .Distinct();

            ApplyProjects(vm, projectDtos);
            ApplyStatusAndProjectHours(vm, response);

            vm.RaisePresenceRegistrationsOnPropertyChanged();
            vm.CalculateTotals();
            vm.DateColumns.EnableClientHours();
        }
        private async void FetchForecasts()
        {
            var response = await _forecastService.GetByUserIdAndMonth(SelectedUserHandler.UserId, SelectedDate.Month, SelectedDate.Year);

            if (response == null)
            {
                IsBusy = false;
                return;
            }

            _forecastRegistrationDataGenerator.MergeHolidays(this, response.Holidays);
            _forecastRegistrationDataGenerator.MergeForecastMonth(this, response.ForecastMonth);
            _projectForecastTypeId = response.ProjectForecastTypeId;

            //await FetchTimeEntries();

            IsBusy = false;
            RaisePresenceRegistrationsOnPropertyChanged();
            InitializeDirtyCheck();
            RaiseCanExecuteActions();

            // Fetch statistics
            FetchStatistics();
        }