public async Task <ActionResult <Product> > Put(Product product) { if (product == null) { return(BadRequest()); } if (!_db.Products.Any(x => x.Id == product.Id)) { return(NotFound()); } ShopStorage shopStorage = new ShopStorage(_db); await shopStorage.UpdateProduct(product.Name, product.Amount); return(Ok(product)); }
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); }