public IQueryable <InventoryItem> GetFilteredCarInventory(string searchParam, string sortColumn, int?sortOrder, int?pageParam)
        {
            BoxXDataReader       dataReader      = BoxXDataReader.Instance;
            IInventoryCollection dataCollection  = ModelFactory.CreateInventoryCollection(dataReader.SchemaPropertyNames);
            IInventoryQuery      query           = QueryFactory.CreateQuery();
            SortOrder?           parsedSortOrder = ParseSortOrder(sortOrder);

            if (parsedSortOrder.HasValue)
            {
                var propertyName = BoxXDataReader.GetPropertyNameFromColumnName(sortColumn);
                if (propertyName.HasValue)
                {
                    query.SortWith(propertyName.Value, parsedSortOrder.Value);
                }
            }

            if (pageParam.HasValue)
            {
                query.PagingWith(pageParam.Value, DataNumPerPage);
            }

            foreach (var propertyName in dataReader.SchemaPropertyNames)
            {
                query.FilterWith(propertyName.ValueLikes(searchParam));
            }

            dataReader.GetData(dataCollection, query);
            return(dataCollection.Items.Cast <InventoryItem>().AsQueryable());
        }
        public IQueryable <InventoryItem> GetAllCarInventory()
        {
            BoxXDataReader       dataReader     = BoxXDataReader.Instance;
            IInventoryCollection dataCollection = ModelFactory.CreateInventoryCollection(dataReader.SchemaPropertyNames);
            IInventoryQuery      query          = QueryFactory.CreateQuery();

            dataReader.GetData(dataCollection, query);

            return(dataCollection.Items.Cast <InventoryItem>().AsQueryable());
        }
コード例 #3
0
        public static IInventoryQuery CreateQueryWithIDs(IEnumerable <int> ids)
        {
            IInventoryQuery query = CreateQuery();

            foreach (int id in ids)
            {
                query.FilterWith(InventoryPropertyName.ID.ValueEquals(id));
            }

            return(query);
        }
        public void GetData(IInventoryCollection dataCollection, IInventoryQuery query)
        {
            GetValueWithoutLocallyFiltering(dataCollection, query);

            if (query.Filters.Any())
            {
                var filteredCollection = dataCollection.Filter(inventoryItem =>
                                                               query.Filters.Any(filter => filter.Match(inventoryItem)));

                dataCollection.CopyFrom(filteredCollection);
            }
        }
コード例 #5
0
 public ReceivingCalculator(IOperation operation, IInventoryQuery inventoryQuery)
 {
     if (operation == null)
     {
         throw new ArgumentNullException("operation");
     }
     if (inventoryQuery == null)
     {
         throw new ArgumentNullException("inventoryQuery");
     }
     _operation      = operation;
     _inventoryQuery = inventoryQuery;
 }
        public static string GetQueryUriOptions(this IInventoryQuery query)
        {
            var queryOptions = new List <string>();

            ParseSearchOption(query.Filters, queryOptions);
            ParseSortOption(query.SortParameters, queryOptions);
            ParsePagingOption(query.PagingParameters, queryOptions);

            if (!queryOptions.Any())
            {
                return("");
            }

            return("?" + string.Join("&", queryOptions.Select(Uri.EscapeUriString)));
        }
コード例 #7
0
 private void InitPlayer()
 {
     playerInventory.Init(new InventoryOptions()
     {
         origin            = ItemOrigin.PlayerInventory,
         resources         = _resources,
         contentTransform  = playerSlotsParent,
         itemDragTransform = itemDragParent,
         slotCount         = 12,
         allowInternalSwap = true
     });
     playerInventory.OnItemDroppedEvent += OnPlayerItemReceive;
     playerInventory.AddItem(_resources.itemDatabase.definitions[0].DefId, 0);
     playerInventory.AddItem(_resources.itemDatabase.definitions[1].DefId, 1);
     playerInventory.AddItem(_resources.itemDatabase.definitions[2].DefId, 2);
     _inventoryQuery = playerInventory;
 }
コード例 #8
0
 private void InitVendor()
 {
     vendorInventory.Init(new InventoryOptions()
     {
         origin            = ItemOrigin.Vendor,
         resources         = _resources,
         contentTransform  = vendorSlotsParent,
         itemDragTransform = itemDragParent,
         slotCount         = 10,
         allowInternalSwap = false
     });
     vendorInventory.OnItemDroppedEvent += OnVendorItemReceive;
     vendorInventory.AddItem(_resources.itemDatabase.definitions[0].DefId, 0);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[1].DefId, 1);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[2].DefId, 2);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[3].DefId, 3);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[4].DefId, 4);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[5].DefId, 5);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[6].DefId, 6);
     vendorInventory.AddItem(_resources.itemDatabase.definitions[7].DefId, 7);
     _vendorQuery = vendorInventory;
 }
        // TODO: Remove this method once the test failed.
        public void GetValueWithoutLocallyFiltering(IInventoryCollection dataCollection, IInventoryQuery query)
        {
            if (dataCollection == null)
            {
                throw new ArgumentNullException("dataCollection");
            }

            if (_model == null)
            {
                _model = BoxXDataCRUDHelpers.GetMetadata(BoxXDataCRUDHelpers.MetadataUrl);
            }

            var requestMessage = new ODataClientRequestMessage(new Uri(BoxXDataCRUDHelpers.DataCollectionUrl + query.GetQueryUriOptions()),
                                                               ODataConstants.MethodGet);

            BoxXDataCRUDHelpers.GetFeedOrEntryRequsetHeaderSetter(requestMessage, AuthUtil.Instance.AccessToken);
            IODataResponseMessage responseMessage = requestMessage.GetResponse();

            using (var messageReader = new ODataMessageReader(responseMessage, new ODataMessageReaderSettings(), _model))
            {
                switch (GetMessageType(responseMessage))
                {
                case ODataMessageType.Feed:
                {
                    ODataReader reader = messageReader.CreateODataFeedReader();
                    ParseDataFromFeedOrEntry(dataCollection, reader);
                    break;
                }

                case ODataMessageType.Entry:
                {
                    ODataReader reader = messageReader.CreateODataEntryReader();
                    ParseDataFromFeedOrEntry(dataCollection, reader);
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException();
                }
                }
            }
        }
コード例 #10
0
ファイル: InventorySchema.cs プロジェクト: wwt/moes-tavern
 public InventorySchema(IInventoryQuery query, IInventoryMutation mutation)
 {
     Query    = query;
     Mutation = mutation;
 }
コード例 #11
0
 public InventoryController(IInventoryQuery inventoryQuery, IInventoryApplication inventoryApplication)
 {
     _inventoryQuery       = inventoryQuery;
     _inventoryApplication = inventoryApplication;
 }