Beispiel #1
0
        public static List <CalendarItem> SearchCalendarItemForWTR(AjourBTForTestContext context, DateTime fromDate, DateTime toDate)
        {
            List <CalendarItem> result = (from item in context.CalendarItems
                                          where ((item.From <= fromDate && item.To >= fromDate) ||
                                                 (item.From >= fromDate && item.From <= toDate))
                                          select item).ToList();

            return(result);
        }
Beispiel #2
0
        public static CalendarItem SearchCalendarItem(int EmployeeID, AjourBTForTestContext context, CalendarItemType type, DateTime fromDate, DateTime toDate)
        {
            CalendarItem item;

            switch (type)
            {
            case CalendarItemType.ReclaimedOvertime:
            {
                item = ((from calendarItem in context.CalendarItems
                         where calendarItem.EmployeeID == EmployeeID &&
                         (calendarItem.Type == CalendarItemType.ReclaimedOvertime || calendarItem.Type == CalendarItemType.PrivateMinus) &&
                         ((calendarItem.From <= fromDate && calendarItem.To >= fromDate) ||
                          (calendarItem.From >= fromDate && calendarItem.From <= toDate))
                         select calendarItem).FirstOrDefault());
            }
            break;

            case CalendarItemType.PaidVacation:
            {
                item = ((from calendarItem in context.CalendarItems
                         where calendarItem.EmployeeID == EmployeeID &&
                         (calendarItem.Type == CalendarItemType.PaidVacation || calendarItem.Type == CalendarItemType.UnpaidVacation) &&
                         ((calendarItem.From <= fromDate && calendarItem.To >= fromDate) ||
                          (calendarItem.From >= fromDate && calendarItem.From <= toDate))
                         select calendarItem).FirstOrDefault());
            }
            break;

            default:
                item = (from calendarItem in context.CalendarItems
                        where calendarItem.EmployeeID == EmployeeID &&
                        calendarItem.Type == type &&
                        ((calendarItem.From <= fromDate && calendarItem.To >= fromDate) ||
                         (calendarItem.From >= fromDate && calendarItem.From <= toDate))
                        select calendarItem).FirstOrDefault();
                break;
            }

            return(item);
        }