Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
2
Indexable
Never
public List<HolidaySubmissionDto> GetListForEmployeeByEmployeeId(long employeeId)
        {

            try
            {
                LBPulseEntities db = new LBPulseEntities();
                LPEmployeeRepository employeeRep = new LPEmployeeRepository();
                List<HolidaySubmission> submissions = db.HolidaySubmission
                    .Where(x => x.LPEmployeeId == employeeId
                    && (x.StartDate.Year == DateTime.UtcNow.Year || x.EndDate.Year == DateTime.UtcNow.Year)
                    && (x.SubmissionStateId == (byte)DictSubmissionState.Pending || x.SubmissionStateId == (byte)DictSubmissionState.PendingCancel || x.SubmissionStateId == (byte)DictSubmissionState.Approved))
                    .OrderBy(x => x.StartDate)
                    .ToList();
                var submissionsDto = MapperHelper.Mapper.Map<List<HolidaySubmissionDto>>(submissions);
                foreach (var submission in submissionsDto)
                {
                    submission.ApproversList = HolidaySubmissionService.GetSubmissionDtoApprovers(submission);

                    LPEmployee employee = employeeRep.GetById(submission.LPEmployeeId);
                    submission.EmployeeFirstName = employee.FirstName;
                    submission.EmployeeLastName = employee.LastName;
                }
                return submissionsDto;
            }
            catch (Exception ex)
            {
                LogHelper.Logger.Error(ex);
                return null;
            }
        }