Exemple #1
0
        public ActionResult <IEnumerable <TimeEntriesResponseDto> > FetchTimeEntries(DateTime fromDateInclusive, DateTime toDateInclusive)
        {
            try
            {
                var user = _userRetriever.RetrieveUser();

                return(Ok(_storage.GetTimeEntries(new TimeEntryQuerySearch
                {
                    UserId = user.Id,
                    FromDateInclusive = fromDateInclusive,
                    ToDateInclusive = toDateInclusive
                })
                          .Select(timeEntry => new
                {
                    User = timeEntry.User,
                    UserEmail = timeEntry.UserEmail,
                    Id = timeEntry.Id,
                    Date = timeEntry.Date.ToDateOnly(),
                    Value = timeEntry.Value,
                    TaskId = timeEntry.TaskId
                })));
            }
            catch (Exception e)
            {
                return(BadRequest(new
                {
                    Message = e.ToString(),
                }));
            }
        }
Exemple #2
0
        public AbsenseDaysDto GetAbsenseDays(int userId, int year, DateTime?intervalStart)
        {
            IEnumerable <TimeEntriesResponseDto> sickLeaveDays = timeEntryStorage.GetTimeEntries(new TimeEntryQuerySearch
            {
                FromDateInclusive = intervalStart ?? DateTime.Now.AddMonths(-12),
                ToDateInclusive   = intervalStart.HasValue ? intervalStart.Value.AddMonths(12) : DateTime.Now,
                UserId            = userId,
                TaskId            = timeEntryOptions.CurrentValue.SickDaysTask
            });

            return(new AbsenseDaysDto
            {
                AbsenseDaysInAYear = sickLeaveGroupSize * sickLeaveGroupAmount,
                UsedAbsenseDays = CalculateUsedSickDays(sickLeaveDays.Where(day => day.Value > 0)),
            });
        }
Exemple #3
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));
        }