예제 #1
0
        public ActionResult <VacationOverviewDto> FetchUsedVacationHours([FromQuery] int?year)
        {
            if (!year.HasValue)
            {
                year = DateTime.Now.Year;
            }

            var user = _userRetriever.RetrieveUser();

            var entries = _timeEntryStorage.GetTimeEntries(new TimeEntryQuerySearch
            {
                FromDateInclusive = new DateTime(year.Value, 01, 01),
                ToDateInclusive   = new DateTime(year.Value, 12, 31),
                UserId            = user.Id,
                TaskId            = _timeEntryOptions.CurrentValue.PaidHolidayTask
            });

            var vacationOverview = VacationExtension.CalculateVacationOverview(entries);

            return(Ok(vacationOverview));
        }
예제 #2
0
        public void CalculateVacationOverView_1Day5HoursVacation_OverviewHas1Day5Hours()
        {
            var timeEntries = new List<TimeEntriesResponseDto>
            {
                {
                    new TimeEntriesResponseDto
                    {
                        Value = 7.5M
                    }
                },
                {
                    new TimeEntriesResponseDto
                    {
                        Value = 5M
                    }
                }
            };

            var overview = VacationExtension.CalculateVacationOverview(timeEntries);

            Assert.Equal(1, overview.TotalDaysUsed);
            Assert.Equal(5, overview.TotalHoursUsed);
        }