コード例 #1
0
        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 !));
        }
コード例 #2
0
 public CustomerController(
     ICustomerService customerService,
     IMapper mapper, IUriGeneratorService uriGeneratorService)
 {
     _customerService     = customerService;
     _uriGeneratorService = uriGeneratorService;
     _mapper = mapper;
 }
コード例 #3
0
 public PostalCodeController(ILocationService locationService,
                             IUriGeneratorService uriGeneratorService,
                             IMapper mapper)
 {
     _locationService     = locationService;
     _uriGeneratorService = uriGeneratorService;
     _mapper = mapper;
 }
コード例 #4
0
 public BrandController(
     IBrandService brandService,
     IUriGeneratorService uriGeneratorService,
     IMapper mapper)
 {
     _brandService        = brandService;
     _uriGeneratorService = uriGeneratorService;
     _mapper = mapper;
 }
コード例 #5
0
 public CategoryController(
     ICategoryService categoryService,
     IUriGeneratorService uriGeneratorService,
     IMapper mapper)
 {
     _categoryService     = categoryService;
     _uriGeneratorService = uriGeneratorService;
     _mapper = mapper;
 }
コード例 #6
0
 public StoreController(
     IUriGeneratorService uriGeneratorService,
     IMapper mapper,
     IStoreService storeService)
 {
     _uriGeneratorService = uriGeneratorService;
     _mapper       = mapper;
     _storeService = storeService;
 }
コード例 #7
0
 public ProductController(
     IProductService productService,
     IUriGeneratorService uriGeneratorService,
     IProductServiceOutputDevice outputDevice,
     IMapper mapper)
 {
     _productService      = productService;
     _uriGeneratorService = uriGeneratorService;
     _outputDevice        = outputDevice;
     _mapper = mapper;
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }