public void Update(User user) { using (var db = new TruckSaleDb()) { db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void Update(Product product) { using (var db = new TruckSaleDb()) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); } }
public void Save(Product product) { using (var db = new TruckSaleDb()) { db.Products.Add(product); db.SaveChanges(); } }
public ProductResource Add(ProductResource resource) { using (var db = new TruckSaleDb()) { db.ProductResources.Add(resource); db.SaveChanges(); } return(resource); }
public ProductResource Remove(long id) { ProductResource result = null; using (var db = new TruckSaleDb()) { var product = db.ProductResources.Single(r => r.Id == id); result = db.ProductResources.Remove(product); db.SaveChanges(); } return(result); }
public Product Delete(long id) { Product result = null; using (var db = new TruckSaleDb()) { var product = db.Products.Single(p => p.Id == id); result = db.Products.Remove(product); db.SaveChanges(); } return(result); }