Пример #1
0
        public List <AttendanceEntity> GetAttendanceDetailsByDate(int id, DateTime date)
        {
            string contractId;

            try
            {
                var attendanceList = new List <AttendanceEntity>();
                var employeeList   = new List <EmployeeSearchResults>();
                using (var context = new FMSGlobalDbContext())
                {
                    contractId = (from c in context.ContractInformation
                                  where c.Id == id
                                  select c.ContractId).First();
                }
                if (contractId != null)
                {
                    var _employeeList = _unitOfWork.EmployeePersonalInfoRepository.GetMany(e => e.ContractId == contractId);
                    foreach (var _employee in _employeeList)
                    {
                        var attendance = _unitOfWork.AttendanceRepository.Get(a => a.EmployeeId == _employee.Id && a.AttendanceDate == date);
                        attendanceList.Add(new AttendanceEntity
                        {
                            Id             = (attendance == null) ? 0 : attendance.Id,
                            ContractId     = contractId,
                            EmployeeId     = _employee.Id,
                            EmployeeName   = _employee.FirstName + ' ' + _employee.LastName,
                            Designation    = _employee.Designation,
                            Attended       = (attendance == null) ? false : attendance.Attended,
                            NoOfHours      = (attendance == null) ? 0 : attendance.NoOfHours,
                            Remarks        = (attendance == null) ? "" : attendance.Remarks,
                            AttendanceDate = date,
                            IsSubmitted    = (attendance == null) ? false : attendance.IsSubmitted
                        });
                    }
                    return(attendanceList);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 public GenericRepository(FMSGlobalDbContext context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }