public void BuyProduct(Delivery invoice) { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); if (Session["UserID"] != null) { //add to sold bool sold = sc.addToPartSold(Convert.ToInt32(Session["UserID"])); sold = sc.addToPcSold(Convert.ToInt32(Session["UserID"])); //add to deliveries //add to invoices bool added = sc.addToPartInvoice(Convert.ToInt32(Session["UserID"])); added = sc.addToPcInvoice(Convert.ToInt32(Session["UserID"])); //REMOVE FROM stock bool removed = sc.decreasePartStock(Convert.ToInt32(Session["UserID"])); removed = sc.decreasePcStock(Convert.ToInt32(Session["UserID"])); //clear cart bool cleared = sc.clearPartCart(Convert.ToInt32(Session["UserID"])); cleared = sc.clearPcCart(Convert.ToInt32(Session["UserID"])); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; } }
public ActionResult LiquidCooler(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cLiquidCooler part = sr.getLiquidCooler(id); return(View(part)); }
public ActionResult EditPC() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cPC> part = sr.getAllPC().ToList(); return(View(part)); }
public ActionResult RAM(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cRAM part = sr.getRAM(id); return(View(part)); }
public ActionResult Checkout(List <Cart> cart) { if (Session["UserID"] == null) { return(this.Redirect(Url.Action("Index", "Login"))); } CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); if (cart == null) { return(this.Redirect(Url.Action("Index", "Checkout"))); } foreach (Cart item in cart) { bool updated = sc.updatePartCart(Convert.ToInt32(Session["UserID"]), item.ProductID, item.Quantity); if (!updated) { updated = sc.updatePcCart(Convert.ToInt32(Session["UserID"]), item.ProductID, item.Quantity); } } var client = sc.getClient(Convert.ToInt32(Session["UserID"])); Delivery view = new Delivery { Address = client.Address, City = client.city, Method = "Collect", Province = client.province, ZipCode = client.ZipCode, Products = getCart(client.ID), Email = client.email, FirstName = client.firstName, Surname = client.Surname, }; return(View(view)); }
public ActionResult Keyboard(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cKeyboard part = sr.getKeyboard(id); return(View(part)); }
public ActionResult EditHeadset() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cHeadset> part = sr.getAllHeadset().ToList(); return(View(part)); }
public List <Cart> getCart(int ID) { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); List <Cart> cart = sc.getPartInvoice(ID).Select(x => new Cart { Discount = x.discount, ImageLink = x.imagelink, Name = x.description, Price = x.price, ProductID = x.part_id, Quantity = x.qua }).ToList(); List <Cart> cartpc = sc.getpcinvoice(ID).Select(x => new Cart { Discount = x.discount, ImageLink = x.imagelink, Name = x.description, Price = x.price, ProductID = x.part_id, Quantity = x.qua }).ToList(); return(cart.Concat(cartpc).ToList()); }
public void AddAllToCart() { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); if (Session["UserID"] != null) { sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["Case"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["Mobo"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["CPU"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["Cooler"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["RAM"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["GPU"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["PSU"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["Fan"]), 1, 100); sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["HDD"]), 1, 100); if (Session["SSD"] != null) { sc.addToPartCart(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["SSD"]), 1, 100); } } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; } }
public ActionResult Microphone(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cMicrophone part = sr.getMicrophone(id); return(View(part)); }
public ActionResult Monitor(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cMonitor part = sr.getMonitor(id); return(View(part)); }
public ActionResult GPU(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cGPU gpu = sr.getGPU(id); return(View(gpu)); }
public ActionResult Speaker(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cSpeaker part = sr.getSpeaker(id); return(View(part)); }
public ActionResult AdminIndex(string search) { if (Convert.ToInt32(Session["UserType"]) > 2 || Session["UserID"] == null) { return(this.Redirect(Url.Action("Index", "Home"))); } CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cEmployee> employees = sr.getAllEmployees().ToList(); if (search == null) { return(View(employees)); } else if (search == "name") { return(View(employees.OrderBy(x => x.First_Name.Trim()).Select(y => y).ToList())); } else if (search == "email") { return(View(employees.OrderBy(x => x.Email.Trim()).Select(y => y).ToList())); } else if (search == "surname") { return(View(employees.OrderBy(x => x.Surname.Trim()).Select(y => y).ToList())); } else if (search == "id") { return(View(employees.OrderBy(x => x.Admin_ID).Select(y => y).ToList())); } else { return(View(employees.Where(x => x.First_Name.Equals(search) || x.Email.Equals(search) || x.Surname.Equals(search)).Select(y => y).ToList())); } }
public void AddToCart(int ID) { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); if (Session["UserID"] != null) { sc.addToPartCart(Convert.ToInt32(Session["UserID"]), ID, 1, 100); } else if (Session["Cart"] != null) { List <int> cartIds = (List <int>)Session["Cart"]; if (cartIds.Where(x => x.Equals(ID)).Select(y => y).FirstOrDefault() == 0) { cartIds.Add(ID); } } else if (Session["Cart"] == null) { Session["Cart"] = new List <int> { ID }; } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; } }
public ActionResult EditGPU() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cGPU> gpu = sr.getAllGPU().ToList(); return(View(gpu)); }
public ActionResult ChangeMonitor(cMonitor monitor, int?quantity, string image) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); PartsStock part = new PartsStock(); if (quantity != null) { part.Quantity = (int)quantity; } else { part.Quantity = sr.getPart(monitor.id).Quantity; } if (image != null && image != "") { part.Image = image; } else { part.Image = sr.getPart(monitor.id).image; } bool done = sr.EditMonitor(monitor, part, monitor.id); if (done) { return(this.Redirect(Url.Action("Complete", "EditProduct"))); } else { return(this.Redirect(Url.Action("Monitor", "EditProduct"))); } }
// GET: ProductPage public ActionResult Index(string id, string filter) { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); var prods = sc.getAllParts(id).ToList(); if (filter != null) { if (filter.Equals("price")) { return(View(prods.OrderBy(x => x.price).Select(x => x).ToList())); } else if (filter.Equals("name")) { return(View(prods.OrderBy(x => x.model.Trim()).Select(x => x).ToList())); } else { return(View(prods.OrderByDescending(x => x.discount).Select(x => x).ToList())); } } else { return(View(prods.OrderByDescending(x => x.discount).Select(x => x).ToList())); } }
public ActionResult Headset(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cHeadset part = sr.getHeadset(id); return(View(part)); }
public ActionResult Case(int id) { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cCase part = sr.getCase(id); return(View(part)); }
public ActionResult EditSpeaker() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cSpeaker> part = sr.getAllSpeaker().ToList(); return(View(part)); }
public ActionResult EditLiquidCooler() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cLiquidCooler> part = sr.getAllLiquidCooler().ToList(); return(View(part)); }
public ActionResult EditMicrophone() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cMicrophone> part = sr.getAllMicrophone().ToList(); return(View(part)); }
public ActionResult Invoice(Delivery delivery) { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); var client = sc.getClient(Convert.ToInt32(Session["UserID"])); if (delivery != null) { delivery.Method = "Deliver"; } else { delivery = new Delivery(); delivery.Method = "Collect"; } delivery.Products = getCart(Convert.ToInt32(Session["UserID"])); foreach (Cart product in delivery.Products) { delivery.SubTotal += Math.Round(product.Price * product.Quantity, 2); delivery.Discount += Math.Round(product.Discount * product.Price * product.Quantity / 100, 2); } delivery.Tax = Math.Round(delivery.SubTotal * 15 / 100, 2); delivery.Total = Math.Round(delivery.SubTotal + delivery.Tax - delivery.Discount, 2); delivery.Email = client.email; delivery.Surname = client.Surname; delivery.FirstName = client.firstName; return(View(delivery)); }
public ActionResult EditMonitor() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cMonitor> part = sr.getAllMonitor().ToList(); return(View(part)); }
public ActionResult EditKeyboard() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); List <cKeyboard> part = sr.getAllKeyboard().ToList(); return(View(part)); }
public ActionResult Cart() { CRUDService.ServiceClient sc = new CRUDService.ServiceClient(); List <Cart> cart = new List <Cart>(); if (Session["UserID"] != null) { cart = getCart(Convert.ToInt32(Session["UserID"])); } if (Session["Cart"] != null) { c_ProductPageInfo part; cart = new List <Cart>(); List <int> ids = (List <int>)Session["Cart"]; foreach (int id in ids) { part = sc.getPart(id); cart.Add(new Cart { Discount = part.discount, ImageLink = part.image, MaxQuantity = part.Quantity, Quantity = 1, Name = part.model, Price = part.price, ProductID = part.ID, cart = "part" }); } } if (Session["PartCart"] != null) { c_PcPageInfo part; if (cart == null) { cart = new List <Cart>(); } List <int> ids = (List <int>)Session["PartCart"]; foreach (int id in ids) { part = sc.getPcInfo(id); cart.Add(new Cart { Discount = part.discount, ImageLink = part.image, MaxQuantity = part.Quantity, Quantity = 1, Name = part.type, Price = part.price, ProductID = part.ID, cart = "pc" }); } } return(View(cart)); }
public ActionResult PC() { CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); PCModel pcmodel = new PCModel { parts = sr.getAllPCparts() }; return(View(pcmodel)); }
// GET: EditUser public ActionResult Index() { if(Session["UserID"] == null) { return this.Redirect(Url.Action("Index", "Home")); } CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cClient client = sr.getClient(Convert.ToInt32(Session["UserID"])); return View(client); }
public ActionResult EditEmployee(int id) { if (Convert.ToInt32(Session["UserType"]) > 2 || Session["UserID"] == null) { return(this.Redirect(Url.Action("Index", "Home"))); } CRUDService.ServiceClient sr = new CRUDService.ServiceClient(); cEmployee client = sr.getEmployee(id); return(View(client)); }