// Inventory Update public void inventoryUpdate(int id, int quantity) { autopartsEntities db = new autopartsEntities(); productdb p = db.productdbs.Find(id); p.qty = p.qty - quantity; db.SaveChanges(); }
public void updateInventory(int id, int quantity) { autopartsEntities db = new autopartsEntities(); cart c = db.carts.Find(id); c.Amount = quantity; db.SaveChanges(); }
// will return all parts added to cart for particular user public List <cart> validateProduct(int ClientID) { string client = ClientID.ToString(); autopartsEntities db = new autopartsEntities(); List <cart> orders = (from x in db.carts where x.ClientId == client && x.isInCart orderby x.DatePurchased select x).ToList(); return(orders); }
public void updateName(int id, string partname) { try { autopartsEntities db = new autopartsEntities(); //Fetch productdb p = db.productdbs.Find(id); p.name = partname; db.SaveChanges(); } catch (Exception) { } }
public productdb chooseProduct(int id) { try { using (autopartsEntities db = new autopartsEntities()) { productdb product = db.productdbs.Find(id); return(product); } } catch (Exception) { return(null); } }
public string insertProductType(producttype productType) { try { autopartsEntities db = new autopartsEntities(); db.producttypes.Add(productType); db.SaveChanges(); return(productType.name + " was successfully inserted"); } catch (Exception e) { return("Error :" + e); } }
public string register(user us) { try { autopartsEntities db = new autopartsEntities(); db.users.Add(us); db.SaveChanges(); return(us.username + " was successfully register."); } catch (Exception e) { return("Error :" + e); } }
public string printOrder(warehouse wh) { try { autopartsEntities db = new autopartsEntities(); db.warehouses.Add(wh); db.SaveChanges(); return("success"); } catch (Exception e) { return("Error :" + e); } }
//Will change the status of inInCart to false once part is purchased public void markOrdersAsPaid(List <cart> carts, string auth) { autopartsEntities db = new autopartsEntities(); if (carts != null) { foreach (cart cart in carts) { cart oldcart = db.carts.Find(cart.id); oldcart.DatePurchased = DateTime.Now; oldcart.isInCart = false; oldcart.authID = auth; } db.SaveChanges(); } }
public guest getGuestDetail(int id) { try { using (autopartsEntities db = new autopartsEntities()) { guest gu = db.guests.Find(id); return(gu); } } catch (Exception) { return(null); } }
public List <productdb> viewProducts() { try { using (autopartsEntities db = new autopartsEntities()) { List <productdb> products = (from x in db.productdbs select x).ToList(); return(products); } } catch (Exception) { return(null); } }
public string insertCart(cart cart) { try { autopartsEntities db = new autopartsEntities(); // AutopartsEntities db = new AutopartsEntities(); db.carts.Add(cart); db.SaveChanges(); return("Part number : " + cart.ProductId + " was successfully added to cart"); } catch (Exception e) { return("Error :" + e); } }
public user getUserDetail(int id) { try { using (autopartsEntities db = new autopartsEntities()) { user us = db.users.Find(id); return(us); } } catch (Exception) { return(null); } }
public List <warehouse> orderList(string auth) { try { using (autopartsEntities db = new autopartsEntities()) { List <warehouse> wh = (from x in db.warehouses where x.paymentID == auth select x).ToList(); return(wh); } } catch (Exception) { return(null); } }
// Will return total number of quantity public int getCost(int ClientID) { try { string client = ClientID.ToString(); autopartsEntities db = new autopartsEntities(); int total = (from x in db.carts where x.ClientId == client && x.isInCart select x.Amount).Sum(); return(total); } catch { return(0); } }
public string deleteCart(int id) { try { autopartsEntities db = new autopartsEntities(); cart p = db.carts.Find(id); db.carts.Attach(p); db.carts.Remove(p); db.SaveChanges(); return("Part was successfully deleted"); } catch (Exception e) { return("Error :" + e); } }
public string deleteProductType(int id) { try { autopartsEntities db = new autopartsEntities(); producttype p = db.producttypes.Find(id); db.producttypes.Attach(p); db.producttypes.Remove(p); db.SaveChanges(); return(p.name + " was successfully deleted"); } catch (Exception e) { return("Error :" + e); } }
public List <cart> cartList(string auth) { try { using (autopartsEntities db = new autopartsEntities()) { List <cart> wh = (from x in db.carts where x.authID == auth select x).ToList(); return(wh); } } catch (Exception) { return(null); } }
public List <productdb> viewProductByType(int typeId) { try { using (autopartsEntities db = new autopartsEntities()) { List <productdb> products = (from x in db.productdbs where x.typeId == typeId select x).ToList(); return(products); } } catch (Exception) { return(null); } }
public string updateGuest(guest g) { try { autopartsEntities db = new autopartsEntities(); //Fetch guest guest = db.guests.Find(1); guest.name = g.name; guest.shippingAddress = g.shippingAddress; db.SaveChanges(); return("success"); } catch (Exception e) { return("Error :" + e); } }
public string updateProductType(int id, producttype productType) { try { autopartsEntities db = new autopartsEntities(); //Fetch producttype p = db.producttypes.Find(id); p.name = productType.name; db.SaveChanges(); return(productType.name + " was successfully updated"); } catch (Exception e) { return("Error :" + e); } }
public admin getCost(int id) { try { autopartsEntities db = new autopartsEntities(); admin ad = db.admins.Find(id); admin a = new admin(); a.shipping = ad.shipping; a.handling = ad.handling; a.localtax = ad.localtax; return(a); } catch (Exception) { return(null); } }
public string updateParts(int id, productdb product) { try { autopartsEntities db = new autopartsEntities(); //Fetch productdb p = db.productdbs.Find(id); p.name = product.name; p.typeId = product.typeId; p.qty = product.qty; p.image = product.image; db.SaveChanges(); return(product.name + " was successfully updated"); } catch (Exception e) { return("Error :" + e); } }
public int returnClientID(string username) { try { using (autopartsEntities db = new autopartsEntities()) { List <user> us = (from x in db.users where x.username == username select x).ToList(); foreach (user user in us) { return(user.ClientId); } return(0); } } catch (Exception) { return(0); } }
public string setCost(admin a) { try { autopartsEntities db = new autopartsEntities(); //Fetch admin ad = db.admins.Find(a.id); ad.shipping = a.shipping; ad.handling = a.handling; ad.localtax = a.localtax; db.SaveChanges(); return("All the rates were successfully updated"); } catch (Exception e) { return("Error :" + e); } }
public string updateCart(int id, cart cart) { try { autopartsEntities db = new autopartsEntities(); //Fetch 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("Part number : " + cart.ProductId + " was successfully updated"); } catch (Exception e) { return("Error :" + e); } }
public int login(string username, string password) { try { using (autopartsEntities db = new autopartsEntities()) { List <user> us = (from x in db.users where x.username == username select x).ToList(); foreach (user user in us) { if (user.password == password) { return(1); } } return(0); } } catch (Exception) { return(0); } }