public Product AddProduct(Product product) { using (var data = new Models.MarketDbContext()) { data.Products.Add(product); data.SaveChanges(); } return(product); }
public Models.Product DeleteProduct(int id) { Models.Product products = new Models.Product(); using (var data = new Models.MarketDbContext()) { products = data.Products.FirstOrDefault(x => x.Id == id); data.Products.Remove(products); data.SaveChanges(); } return(products); }