예제 #1
0
        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));
            }
        }
예제 #2
0
        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);
        }