예제 #1
0
        public async Task <List <OrderDetails> > FindAllAsync(Expression <Func <OrderDetails, bool> > predicate = null)
        {
            var filter  = MongoHelpers.GetDocumentFilter(predicate);
            var details = (await _orderDetailsCollection.FindAsync(filter)).ToList();

            return(details);
        }
예제 #2
0
        public async Task <List <Publisher> > FindAllAsync(Expression <Func <Publisher, bool> > predicate = null)
        {
            var filter     = MongoHelpers.GetDocumentFilter(predicate);
            var publishers = (await _publishersCollection.FindAsync(filter)).ToList();

            return(publishers);
        }
예제 #3
0
        public async Task <OrderDetails> FindSingleAsync(Expression <Func <OrderDetails, bool> > predicate)
        {
            var filter  = MongoHelpers.GetDocumentFilter(predicate);
            var details = (await _orderDetailsCollection.FindAsync(filter)).FirstOrDefault();

            return(details);
        }
예제 #4
0
        public async Task <Publisher> FindSingleAsync(Expression <Func <Publisher, bool> > predicate)
        {
            var filter    = MongoHelpers.GetDocumentFilter(predicate);
            var publisher = (await _publishersCollection.FindAsync(filter)).FirstOrDefault();

            return(publisher);
        }
예제 #5
0
        public async Task <List <Product> > FindAllAsync(Expression <Func <Product, bool> > predicate = null)
        {
            var filter = MongoHelpers.GetDocumentFilter(predicate);
            var games  = (await _productsCollection.FindAsync(filter)).ToList();

            return(games);
        }
예제 #6
0
        public async Task UpdateKeyAsync(string productId, string key)
        {
            var existingProduct = await GetById(productId);

            var oldValueInstance = existingProduct.Clone();

            existingProduct.Key = key;
            var filter = MongoHelpers.GetDocumentFilter <Product>(p => p.Id == productId);
            await _productsCollection.ReplaceOneAsync(filter, existingProduct);

            var entry = new LogEntry <Product>(Operation.Update, oldValueInstance, existingProduct);

            _logger.Log(entry);
        }
예제 #7
0
        public async Task UpdateUnitsInStockAsync(string key, short unitsInStock)
        {
            var existingProduct = await FindSingleAsync(p => p.Key == key);

            var oldValueInstance = existingProduct.Clone();

            existingProduct.UnitsInStock = unitsInStock;
            var filter = MongoHelpers.GetDocumentFilter <Product>(p => p.Key == key);
            await _productsCollection.ReplaceOneAsync(filter, existingProduct);

            var entry = new LogEntry <Product>(Operation.Update, oldValueInstance, existingProduct);

            _logger.Log(entry);
        }
예제 #8
0
        public async Task <Order> FindSingleAsync(Expression <Func <Order, bool> > predicate)
        {
            var filter = MongoHelpers.GetDocumentFilter(predicate);
            var order  = (await _ordersCollection.FindAsync(filter)).FirstOrDefault();

            if (order == null)
            {
                return(null);
            }

            await SetupDetails(new[] { order });
            await SetupGameDetails(order.Details);

            return(order);
        }