public QueryResult<CommodityWarehouseStorageNote> Query(QueryDocument query)//List<SourcingDocument> Query(QueryDocument query)
        {
            var commodityWarehouseStorageQuery = documents.AsQueryable();

            var queryResult = new QueryResult<CommodityWarehouseStorageNote>();

            commodityWarehouseStorageQuery=commodityWarehouseStorageQuery.Where(n => n.DocumentStatusId == (int)query.DocumentSourcingStatusId);

            queryResult.Count = commodityWarehouseStorageQuery.Count();
            commodityWarehouseStorageQuery = commodityWarehouseStorageQuery.OrderByDescending(n => n.DocumentDate);
            if (query.Skip.HasValue && query.Take.HasValue)
                commodityWarehouseStorageQuery = commodityWarehouseStorageQuery.Skip(query.Skip.Value).Take(query.Take.Value);

            var result = commodityWarehouseStorageQuery.ToList();
            queryResult.Data = result.Select(Map).OfType<CommodityWarehouseStorageNote>().ToList();

            return queryResult;

            //return documents.Where(n => n.DocumentStatusId == (int)query.DocumentSourcingStatusId).OrderByDescending(n => n.DocumentDate).ToList().Select(Map).ToList();
        }
        private void LoadWarehouseEntriesList()
        {
            using (var c = ObjectFactory.Container.GetNestedContainer())
            {
                
                var query = new QueryDocument();
                query.Skip = ItemsPerPage * (CurrentPage - 1);
                query.Take = ItemsPerPage;
                query.ShowInactive = true;
                query.DocumentSourcingStatusId = (int) DocumentSourcingStatus.Confirmed;

                //var rawList = c.GetInstance<ICommodityWarehouseStorageRepository>().Query(query).OfType<CommodityWarehouseStorageNote>().ToList();
                //WarehouseEntryList.Clear();
                //RowNumber = 1;
                //rawList.ForEach(n=>WarehouseEntryList.Add(Map(n)));

                var rawList = c.GetInstance<ICommodityWarehouseStorageRepository>().Query(query);
                var data = rawList.Data.OfType<CommodityWarehouseStorageNote>();
                WarehouseEntryList.Clear();
                RowNumber = 1;
                // rawList.ForEach(n => WarehousePendingStorageList.Add(Map(n)));

                _pagedCommoditySupplierInventoryLevel = new PagenatedList<CommodityWarehouseStorageNote>(data.AsQueryable(),
                                                                                       CurrentPage,
                                                                                       ItemsPerPage,
                                                                                       rawList.Count, true);

                _pagedCommoditySupplierInventoryLevel.ForEach(n => WarehouseEntryList.Add(Map(n)));
                UpdatePagenationControl();
               
            }    
        }
        private void LoadUnassignedGrn(Guid id)
        {
            using (var c = NestedContainer)
            {
                var query = new QueryDocument();
                query.Skip = ItemsPerPage * (CurrentPage - 1);
                query.Take = ItemsPerPage;
                query.ShowInactive = true;
                query.DocumentSourcingStatusId = (int)DocumentSourcingStatus.Closed;

                var rawList = c.GetInstance<ICommodityWarehouseStorageRepository>().Query(query).Data.AsQueryable();
                var data = rawList.Where(p => p.DocumentRecipientCostCentre.Id == id).ToList();

                UnassignedWarehouseGrnListItem.Clear();

                data.ForEach(n => UnassignedWarehouseGrnListItem.Add(Map(n)));


            }
        }