public void InsertUserDetail(UserInformation userDetail) { GarageDBEntities6 db = new GarageDBEntities6(); db.UserInformations.Add(userDetail); db.SaveChanges(); }
public void UpdateQuantity(int id, int quantity) { GarageDBEntities6 db = new GarageDBEntities6(); Cart cart = db.Carts.Find(id); cart.Amount = quantity; db.SaveChanges(); }
public string InsertProductType(ProductType productType) { try { GarageDBEntities6 db = new GarageDBEntities6(); db.ProductTypes.Add(productType); db.SaveChanges(); return(productType.Name + "was succesfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public string InsertCart(Cart cart) { try { GarageDBEntities6 db = new GarageDBEntities6(); db.Carts.Add(cart); db.SaveChanges(); return(cart.DatePurchased + "was succesfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public void MarkOrderAsPaid(List <Cart> carts) { GarageDBEntities6 db = new GarageDBEntities6(); if (carts != null) { foreach (Cart cart in carts) { Cart oldCart = db.Carts.Find(cart.ID); oldCart.DatePurchased = DateTime.Now; oldCart.IsInCart = false; } db.SaveChanges(); } }
public string DeleteProductType(int id) { try { GarageDBEntities6 db = new GarageDBEntities6(); ProductType productType = db.ProductTypes.Find(id); db.ProductTypes.Attach(productType); db.ProductTypes.Remove(productType); db.SaveChanges(); return(productType.Name + "was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProductType(int id, ProductType productType) { try { GarageDBEntities6 db = new GarageDBEntities6(); ProductType p = db.ProductTypes.Find(id); p.Name = productType.Name; db.SaveChanges(); return(productType.Name + "was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteCart(int id) { try { GarageDBEntities6 db = new GarageDBEntities6(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return(cart.DatePurchased + "was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCart(int id, Cart cart) { try { GarageDBEntities6 db = new GarageDBEntities6(); Cart p = db.Carts.Find(id); p.DatePurchased = cart.DatePurchased; p.ClientID = cart.ClientID; p.Amount = cart.Amount; p.IsInCart = cart.IsInCart; p.ProductID = cart.ProductID; db.SaveChanges(); return(cart.DatePurchased + "was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProduct(int id, Product product) { try { GarageDBEntities6 db = new GarageDBEntities6(); //Fetch object from db Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.TypeID = product.TypeID; p.Description = product.Description; p.Image = product.Image; db.SaveChanges(); return(product.Name + " was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }