public List <Attendance> Read(AttendanceFilter attendanceFilter)
        {
            if (attendanceFilter.EmployeeIds == null)
            {
                attendanceFilter.EmployeeIds = new List <int>();
            }
            if (attendanceFilter.EmployeeIdsOfSelectedDepartments == null)
            {
                attendanceFilter.EmployeeIdsOfSelectedDepartments = new List <int>();
            }
            if (attendanceFilter.ManagerEmployeeIds == null)
            {
                attendanceFilter.ManagerEmployeeIds = new List <int>();
            }

            Expression <Func <EAttendance, bool> > predicate =
                a => (((a.TimeIn >= attendanceFilter.TimeInFrom && a.TimeIn <= attendanceFilter.TimeInTo) ||
                       (a.TimeOut >= attendanceFilter.TimeInFrom && a.TimeOut <= attendanceFilter.TimeInTo)) ||
                      (!attendanceFilter.TimeInFrom.HasValue || !attendanceFilter.TimeInTo.HasValue)) &&
                (!attendanceFilter.EmployeeIds.Any() || attendanceFilter.EmployeeIds.Contains(a.EmployeeId)) &&
                (!attendanceFilter.EmployeeIdsOfSelectedDepartments.Any() || attendanceFilter.EmployeeIdsOfSelectedDepartments.Contains(a.EmployeeId)) &&
                (!attendanceFilter.ManagerEmployeeIds.Any() || attendanceFilter.ManagerEmployeeIds.Contains(a.ManagerEmployeeId));

            //(a.TimeIn >= attendanceFilter.TimeInFrom) && (a.TimeOut <= attendanceFilter.TimeInTo) ||

            //Expression<Func<EAttendance, bool>> predicate =
            //    a => (attendanceFilter.TimeInFrom.HasValue || a.TimeIn >= attendanceFilter.TimeInFrom)
            //    && (attendanceFilter.TimeInTo.HasValue || a.TimeOut >= attendanceFilter.TimeInTo)
            //    && (attendanceFilter.ManagerEmployeeIds.Any() || attendanceFilter.ManagerEmployeeIds.Contains(a.ManagerEmployeeId));
            //looks like we need to add EmployeeId
            List <EAttendance> eAttendances = _iDAttendance.List(predicate);

            return(Attendances(eAttendances));
        }
Beispiel #2
0
        public List <Attendance> Read()
        {
            List <EAttendance> eAttendances = _iDAttendance.List <EAttendance>(a => true);

            return(Attendances(eAttendances));
        }