public static PagedResponse <T> CreatePaginatedResponse <T>( IUriGeneratorService uriGeneratorService, PaginationParams pagination, IEnumerable <T> response) { var nextPage = pagination.PageNumber >= 1 ? uriGeneratorService.GetAllEntitiesUri(new PaginationQuery(pagination.PageNumber + 1, pagination.PageSize)) .ToString() : null; var previousPage = pagination.PageNumber - 1 >= 1 ? uriGeneratorService.GetAllEntitiesUri(new PaginationQuery(pagination.PageNumber - 1, pagination.PageSize)) .ToString() : null; //TODO similar expression var enumerable = response as T[] ?? response.ToArray(); int?pageNumber = pagination.PageNumber >= 1 ? pagination.PageNumber : (int?)null; int?pageSize = pagination.PageSize >= 1 ? pagination.PageSize : (int?)null; return(new PagedResponse <T>(enumerable, pageNumber, pageSize, nextPage !, previousPage !)); }
public CustomerController( ICustomerService customerService, IMapper mapper, IUriGeneratorService uriGeneratorService) { _customerService = customerService; _uriGeneratorService = uriGeneratorService; _mapper = mapper; }
public PostalCodeController(ILocationService locationService, IUriGeneratorService uriGeneratorService, IMapper mapper) { _locationService = locationService; _uriGeneratorService = uriGeneratorService; _mapper = mapper; }
public BrandController( IBrandService brandService, IUriGeneratorService uriGeneratorService, IMapper mapper) { _brandService = brandService; _uriGeneratorService = uriGeneratorService; _mapper = mapper; }
public CategoryController( ICategoryService categoryService, IUriGeneratorService uriGeneratorService, IMapper mapper) { _categoryService = categoryService; _uriGeneratorService = uriGeneratorService; _mapper = mapper; }
public StoreController( IUriGeneratorService uriGeneratorService, IMapper mapper, IStoreService storeService) { _uriGeneratorService = uriGeneratorService; _mapper = mapper; _storeService = storeService; }
public ProductController( IProductService productService, IUriGeneratorService uriGeneratorService, IProductServiceOutputDevice outputDevice, IMapper mapper) { _productService = productService; _uriGeneratorService = uriGeneratorService; _outputDevice = outputDevice; _mapper = mapper; }
public OrderController( IOrderService orderService, IUriGeneratorService uriGeneratorService, IAuthenticationContext authenticationContext, ICustomerService customerService, IMapper mapper) { _orderService = orderService; _mapper = mapper; _customerService = customerService; _authenticationContext = authenticationContext; _uriGeneratorService = uriGeneratorService; _authenticationContext.AttachCurrentContext(this); }
public static PagedQueryResponse <T> CreatePaginatedQueryResponse <T>( IUriGeneratorService uriGeneratorService, PaginationParams pagination, IEnumerable <T> response, int count) { //safe casting var enumerable = response.ToList(); var pagedResponse = CreatePaginatedResponse(uriGeneratorService, pagination, enumerable); var queryResponse = new PagedQueryResponse <T> { Data = pagedResponse.Data, PageNumber = pagedResponse.PageNumber, PageSize = pagedResponse.PageSize, QueriedItems = count, FetchedItems = enumerable.Count() > pagination.PageSize ? enumerable.Count() : pagination.PageSize }; return(queryResponse); }