public async Task Seed()
        {
            var priceReductions = await Get();

            if (priceReductions != null && priceReductions.ToList().Count == 0)
            {
                PriceReduction priceReduction = new PriceReduction {
                    DayOfWeek = 2, Reduction = 0.2
                };
                await Create(priceReduction);
            }
        }
Beispiel #2
0
        public Product Get(string id)
        {
            Product currentproduct = new Product();

            PriceReduction currentreduction = new PriceReduction();


            currentproduct = _products.Find <Product>(prod => prod.Id == id).FirstOrDefault();

            int currentday = getDay();

            if (currentday != -1)
            {
                currentreduction     = _reductions.Find <PriceReduction>(reduction => reduction.DayOfWeek == currentday).FirstOrDefault();
                currentproduct.Price = currentproduct.Price - currentreduction.Reduction;
            }



            return(currentproduct);
        }
        public async Task <ObjectId> Create(PriceReduction priceReduction)
        {
            await _priceReductionsCollection.InsertOneAsync(priceReduction);

            return(priceReduction.Id);
        }