public override Cart Update(Cart entity) { using (var context = new TheBestShopContext()) { context.Carts.Update(entity); context.SaveChanges(); return(entity); } }
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); } }
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(); } }
public T Create(T entity) { _contextt.Entry(entity).State = EntityState.Added; _contextt.SaveChanges(); return(entity); }