Ejemplo n.º 1
0
 public void InsertEntity(Order entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Orders.Add(entity);
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void InsertEntity(Product entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Products.Add(entity);
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void InsertEntity(Category entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Categories.Add(entity);
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void ModifyEntity(OrderDetails entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.OrderDetails.Attach(entity);
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public void ModifyEntity(Order entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Orders.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Modified;
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void RemoveEntity(Product entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Products.Remove(entity);
         EntityContext.Products.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public void RemoveEntity(Order entity)
 {
     // TODO: Order and order details should be deleted
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Orders.Remove(entity);
         EntityContext.Orders.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public void RemoveEntity(Category entity)
 {
     // TODO : check if all the product exist in the category should be deleted or not
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Categories.Remove(entity);
         EntityContext.Categories.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 9
0
 public void RemoveEntity(OrderDetails entity)
 {
     // TODO: Remove the OrderDetail from the main list and the list in the Order
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.OrderDetails.Remove(entity);
         EntityContext.OrderDetails.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Ejemplo n.º 10
0
 //   Hint:The path is to set the IsActive property to 1 and we know that if a
 // property's IsActive value is 1, it is a deleted entity.
 public void RemoveEntity(Customer entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //entity.IsActive = 1;
         //EntityContext.Customers.Attach(entity);
         //EntityContext.Entry(entity).State = EntityState.Modified;
         //EntityContext.Customers.Remove(entity);
         EntityContext.Customers.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }