public Paganation <EmployeeDTO> GetAll(SerachPaganationDTO <EmployeeDTO> dto) { try { var a = new EmployeeDTO(); var listEmployee = _repository.Queryable(); var listDepartment = _repositoryDepartment.Queryable(); var listPosition = _repositoryPosition.Queryable(); var employeeDTO = (from emp in listEmployee from dep in listDepartment from pos in listPosition where emp.DepartmentId == dep.Id && emp.PositionId == pos.Id select new EmployeeDTO { Id = emp.Id, Name = emp.Name, PositionName = pos.Name, DepartmentName = dep.Name }).OrderBy(it => it.DepartmentName) .ThenBy(it => it.Name) .Take(dto.Take) .Skip(dto.Skip) .ToList(); var result = _mapper.Map <SerachPaganationDTO <EmployeeDTO>, Paganation <EmployeeDTO> >(dto); result.Data = employeeDTO; return(result); } catch (Exception ex) { throw new Exception($"Couldn't retrieve entities: {ex.Message}"); } }
public IActionResult GetAll([FromQuery] SerachPaganationDTO <EmployeeDTO> dto) { var result = _employeeService.GetAll(dto); if (result == null) { return(Ok(false)); } return(Ok(result)); }
public Paganation <ReadProductDto> GetPage(int index) { //var PageInfo = new PaginationInfo() { index = index }; //PageInfo.totalItem = repository.Queryable().Count(); //var Data = repository.Queryable().Skip(0).Take(8).ToList(); //PageInfo.data = mapper.Map<List<Product>, List<ReadProductDto>>(Data); //var PageResult = mapper.Map<PaginationInfo, ReadPagination>(PageInfo); //return PageResult; var PageInfo = new SerachPaganationDTO <ReadProductDto>() { PageNumber = index }; var DataProduct = repository.Queryable().Take(PageInfo.Take).Skip(PageInfo.Skip).ToList(); var DataReadProductDto = mapper.Map <List <Product>, List <ReadProductDto> >(DataProduct); var TotalItem = repository.Queryable().Count(); var Result = mapper.Map <SerachPaganationDTO <ReadProductDto>, Paganation <ReadProductDto> >(PageInfo); Result.InputData(TotalItem, DataReadProductDto); return(Result); }