Esempio n. 1
0
 public override Cart Update(Cart entity)
 {
     using (var context = new TheBestShopContext())
     {
         context.Carts.Update(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 2
0
 public override Order Update(Order entity)
 {
     using (var context = new TheBestShopContext())
     {
         context.Orders.Update(entity);
         context.SaveChanges();
         return(entity);
     }
 }
 public override Product Update(Product entity)
 {
     using (var context = new TheBestShopContext())
     {
         context.Products.Update(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 4
0
 public void RemoveFromCart(int cartId, string productId = null)
 {
     using (var context = new TheBestShopContext())
     {
         if (productId != null)
         {
             context.Database.ExecuteSqlCommand($"delete from CartItems where Carts_Id={cartId} and Products_Id={Convert.ToInt32(productId)}");
         }
         else
         {
             context.Database.ExecuteSqlCommand($"delete from CartItems where Carts_Id={cartId}");
         }
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public T Create(T entity)
 {
     _contextt.Entry(entity).State = EntityState.Added;
     _contextt.SaveChanges();
     return(entity);
 }