public void Destroy(GroupVM group) { if (!UpdateDatabase) { var target = GetAll().FirstOrDefault(g => g._id == group._id); if (target != null) { GetAll().Remove(target); } } else { //var entity = new Product(); //entity.ProductID = product.ProductID; //entities.Products.Attach(entity); //entities.Products.Remove(entity); //var orderDetails = entities.Order_Details.Where(pd => pd.ProductID == entity.ProductID); //foreach (var orderDetail in orderDetails) //{ // entities.Order_Details.Remove(orderDetail); //} //entities.SaveChanges(); } }
public void Create(GroupVM group) { if (!UpdateDatabase) { } else { } }
public void Update(GroupVM product) { if (!UpdateDatabase) { //var target = One(e => e.ProductID == product.ProductID); //if (target != null) //{ // target.ProductName = product.ProductName; // target.UnitPrice = product.UnitPrice; // target.UnitsInStock = product.UnitsInStock; // target.Discontinued = product.Discontinued; // target.CategoryID = product.CategoryID; // target.Category = product.Category; //} } else { ////var entity = new GroupVM(); ////entity.ProductID = product.ProductID; ////entity.ProductName = product.ProductName; ////entity.UnitPrice = product.UnitPrice; ////entity.UnitsInStock = (short)product.UnitsInStock; ////entity.Discontinued = product.Discontinued; ////entity.CategoryID = product.CategoryID; ////if (product.Category != null) ////{ //// entity.CategoryID = product.Category.CategoryID; ////} ////entities.Products.Attach(entity); ////entities.Entry(entity).State = EntityState.Modified; ////entities.SaveChanges(); } }