public async Task <ActionResult <Product> > Post(Product product)
        {
            if (product == null)
            {
                return(BadRequest());
            }
            ShopStorage shopStorage = new ShopStorage(_db);
            await shopStorage.AddProduct(product);

            return(Ok(product));
        }
Example #2
0
        public void Reserve_10Threads_1000Times_Test()
        {
            var context = new DatabaseContext(_options);

            _shopStorage = new ShopStorage(context);

            var result = _shopStorage.DeleteAllReserve(_productName).Result;

            var product = _shopStorage.AddProduct(_productName, 100).Result ?? _shopStorage.UpdateProduct(_productName, 100).Result;

            Task[] tasks = new Task[10];
            for (int i = 0; i < 10; i++)
            {
                tasks[i] = new Task(Reserve_RndAmount_1000Times);
                tasks[i].Start();
            }

            Task.WaitAll(tasks);
        }