public Product GetOne(int productId, int sleep = 0) { Thread.Sleep(sleep); using (var ctx = new Northwind.Services.Data.NorthwindDbContext()) { return(ctx.Products.FirstOrDefault(x => x.ProductId == productId)); } }
public async Task <Product> Delete(int productId, int sleep = 0) { Thread.Sleep(sleep); Product productToDelete = null; using (var ctx = new Northwind.Services.Data.NorthwindDbContext()) { productToDelete = ctx.Products.FirstOrDefault(x => x.ProductId == productId); ctx.Products.Remove(productToDelete ?? throw new InvalidOperationException()); ctx.SaveChanges(); } return(productToDelete); }