Exemple #1
0
        public List <AttendanceViewModel> GetAll(string filterByName = "", int orderByName = 0, int orderByCode = 0, int orderByValue = 0)
        {
            var data = _attendanceRepository.Find(x => x.DeleteFlag != DeleteFlg.Delete);

            if (!string.IsNullOrEmpty(filterByName))
            {
                //data = data.Where(x => x.Name.ToUpper() == filterByName.ToUpper());
                data = data.Where(x => x.Name.Contains(filterByName) || x.Value.Contains(filterByName) || x.Code.Contains(filterByName));
            }
            return(_mapper.Map <List <Attendance>, List <AttendanceViewModel> >(data.ToList()));
        }
        public IHttpActionResult GetAttendance(int id)
        {
            Attendance Attendance = (Attendance)attendanceRepo.Find(id);

            if (Attendance == null)
            {
                return(NotFound());
            }

            Mapper.Initialize(c => c.CreateMap <Attendance, AttendanceDTO>());

            AttendanceDTO AttendanceDTO = Mapper.Map <AttendanceDTO>(Attendance);

            return(Ok(AttendanceDTO));
        }
Exemple #3
0
        public virtual IEnumerable <AttendanceDao> GetAttendanceAndHoursByDate(DateTime startDate, DateTime endDate, int employeeId)
        {
            endDate = endDate.AddDays(1).AddSeconds(-1);
            var attendances   = _attendanceRepository.Find(a => a.IsActive && ((a.ClockIn >= startDate && a.ClockIn <= endDate) || (a.ClockOut >= startDate && a.ClockOut <= endDate)));
            var employeeHours = _employeeHoursRepository.GetAllActive();

            var query = from attendance in attendances
                        join employeeHour in employeeHours on attendance.AttendanceId equals employeeHour.OriginAttendanceId into result
                        from subResult in result.DefaultIfEmpty()
                        group subResult by attendance into grouped
                        select new AttendanceDao
            {
                EmployeeId    = grouped.Key.EmployeeId,
                AttendanceId  = grouped.Key.AttendanceId,
                FirstName     = grouped.Key.Employee.FirstName,
                ClockIn       = grouped.Key.ClockIn,
                ClockOut      = grouped.Key.ClockOut,
                MiddleName    = grouped.Key.Employee.MiddleName,
                LastName      = grouped.Key.Employee.LastName,
                EmployeeHours = grouped
            };

            if (employeeId > 0)
            {
                query = query.Where(x => x.EmployeeId == employeeId);
            }

            return(query.ToList());
        }
Exemple #4
0
        public async Task <IActionResult> GetAttendances([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var attendance = await _attendanceRepository.Find(id);

            if (attendance == null)
            {
                return(NotFound());
            }

            return(Ok(attendance));
        }
 public Attendance GetAttendanceById(long id)
 {
     return(attendanceRepository.Find(id));
 }