示例#1
0
 public async Task <Product> UpdateProductAsync(Product Product)
 {
     using (var context = new DataContextProducts())
     {
         context.Entry(Product).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
     return(Product);
 }
示例#2
0
        public async Task DeleteProductAsync(int id)
        {
            using (var context = new DataContextProducts())
            {
                var Product = await context.Products.FirstOrDefaultAsync(f => f.ProductId == id);

                context.Entry(Product).State = EntityState.Deleted;
                await context.SaveChangesAsync();
            }
        }