public async Task <PagingResult <LeaveDto> > GetAllLeaves(int page, int pageSize, int employeeId, DateTime fromDate, DateTime toDate, bool?isApproved)
        {
            try
            {
                Expression <Func <Leave, bool> > filter = x => x.EmployeeId == employeeId &&
                                                          fromDate.Date <= x.FromDate &&
                                                          x.ToDate <= toDate &&
                                                          (isApproved == null || x.IsApproved == isApproved);

                IOrderedQueryable <Leave> OrderBy(IQueryable <Leave> x)
                {
                    return(x.OrderByDescending(y => y.FromDate));
                }

                IIncludableQueryable <Leave, object> Includes(IQueryable <Leave> x)
                {
                    return(x.Include(y => y.Employee).Include(y => y.LeaveType));
                }

                int skip = (page - 1) * pageSize;


                int totalData = await _leaveRepository.CountAsync(filter);

                List <Leave> leaves = new List <Leave>();

                if (totalData > 0)
                {
                    leaves = await _leaveRepository.GetAllAsync(filter, Includes, OrderBy, skip, pageSize, true);
                }

                return(new PagingResult <LeaveDto>
                {
                    Data = leaves.Select(LeaveMapper.Map).ToList(),
                    TotalCount = totalData
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error when get all leaves");
                throw;
            }
        }