public void UpdateQuantity(int id, int quantity) { ShopdbEntities3 db = new ShopdbEntities3(); Cart cart = db.Carts.Find(id); cart.Quantity = quantity; db.SaveChanges(); }
public string InsertProductType(Product_Type productType) { try { ShopdbEntities3 db = new ShopdbEntities3(); db.Product_Type.Add(productType); db.SaveChanges(); return(productType.Type + " was succesfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public void MarkOrderAsPaid(List <Cart> carts) { ShopdbEntities3 db = new ShopdbEntities3(); if (carts != null) { foreach (Cart cart in carts) { Cart oldCart = db.Carts.Find(cart.Cart_ID); oldCart.Order_Date = DateTime.Now; oldCart.IsInCart = false; } db.SaveChanges(); } }
public string InsertCart(Cart cart) { try { ShopdbEntities3 db = new ShopdbEntities3(); db.Carts.Add(cart); db.SaveChanges(); return(cart.Order_Date + " order was succesfully added"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteProductType(int id) { try { ShopdbEntities3 db = new ShopdbEntities3(); Product_Type productType = db.Product_Type.Find(id); db.Product_Type.Attach(productType); db.Product_Type.Remove(productType); db.SaveChanges(); return(productType.Type + " was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProductType(int id, Product_Type productType) { try { ShopdbEntities3 db = new ShopdbEntities3(); Product_Type p = db.Product_Type.Find(id); p.Type = productType.Type; db.SaveChanges(); return(productType.Type + " was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteCart(int id) { try { ShopdbEntities3 db = new ShopdbEntities3(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return(cart.Order_Date + " was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCart(int id, Cart cart) { try { ShopdbEntities3 db = new ShopdbEntities3(); Cart p = db.Carts.Find(id); p.Order_Date = cart.Order_Date; p.Customer_ID = cart.Customer_ID; p.IsInCart = cart.IsInCart; p.Product_ID = cart.Product_ID; db.SaveChanges(); return(cart.Order_Date + " was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProduct(int id, Product product) { try { ShopdbEntities3 db = new ShopdbEntities3(); Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.Product_Type_ID = product.Product_Type_ID; p.Description = product.Description; p.Image = product.Image; db.SaveChanges(); return(product.Name + " was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }