public static void AddProduct(this NorthwindEntities db, ProductViewModel product) { var entity = product.ToProduct(); db.Products.Add(entity); db.SaveChanges(); product.ProductID = entity.ProductID; }
public static void AddProduct(this NorthwindEntities db, ProductViewModel product) { var entity = product.ToProduct(); db.Products.Add(entity); db.SaveChanges(); product.ProductID = entity.ProductID; }
public static void UpdateProduct(this NorthwindEntities db, ProductViewModel product) { var entity = product.ToProduct(); entity.ProductID = product.ProductID; db.Products.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); }
public static void UpdateProduct(this NorthwindEntities db, ProductViewModel product) { var entity = product.ToProduct(); entity.ProductID = product.ProductID; db.Products.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); }