public async Task <Product> UpdateProductAsync(Product Product) { using (var context = new DataContextProducts()) { context.Entry(Product).State = EntityState.Modified; await context.SaveChangesAsync(); } return(Product); }
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(); } }