public async Task <ActionResult <IReadOnlyList <Department> > > GetDepWithSpec(Guid id) { var spec = new DepartmentWithUsersSpecification(id); var dep = await _depRepo.GetEntityWithSpec(spec); if (dep == null) { return(NotFound(new ApiResponse(404))); } return(Ok(dep)); }
public async Task <ActionResult <Pagination <DepartmentToReturnDto> > > GetAllWithSpec([FromQuery] DepartmentSpecParams departmentParams) { var spec = new DepartmentWithUsersSpecification(departmentParams); var countSpec = new DepartmentWithUsersCountSpecification(departmentParams); var totalItems = await _depRepo.CountAsync(countSpec); var deps = await _depRepo.GetListWithSpec(spec); var data = _mapper.Map <IReadOnlyList <Department>, IReadOnlyList <DepartmentToReturnDto> >(deps); // var data = await _depRepo.GetListWithSpec(spec); // return Ok(await _depRepo.GetListWithSpec(spec)); return(Ok(new Pagination <DepartmentToReturnDto>(departmentParams.PageIndex, departmentParams.PageSize, totalItems, data))); }