// GET: bestelling/Take/5 public ActionResult Take(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bestelling bestelling = db.bestellings.Find(id); if (bestelling == null) { return(HttpNotFound()); } return(View(bestelling)); }
public ActionResult Create([Bind(Include = "bestellingid,aantal,statusid,besteldatum,ophaaldatum,bestelregelid,medewerkerid,klantid,vestigingid,totaalprijs")] bestelling bestelling) { if (ModelState.IsValid) { db.bestellings.Add(bestelling); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.klantid = new SelectList(db.klants, "klantid", "voorletters", bestelling.klantid); ViewBag.medewerkerid = new SelectList(db.medewerkers, "medewerkerid", "voorletters", bestelling.medewerkerid); ViewBag.statusid = new SelectList(db.status, "statusid", "status1", bestelling.statusid); ViewBag.vestigingid = new SelectList(db.vestigings, "vestigingsid", "vestigingsnaam", bestelling.vestigingid); return(View(bestelling)); }
public ActionResult DeleteConfirmed(int id) { bestelling bestelling = db.bestellings.Find(id); var vandaag = DateTime.Now; if (bestelling.besteldatum >= vandaag || bestelling.besteldatum <= vandaag) { //Id 4 is geannuleerd. bestelling.statusid = 4; db.SaveChanges(); ViewBag.Succes = "Geannuleerd"; return(RedirectToAction("Index")); } ViewBag.Error = "U kunt uw bestelling niet annuleren op de dag dat uw bestelling geweest is."; return(RedirectToAction("Index")); }
// GET: bestellings/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bestelling bestelling = db.bestellings.Find(id); if (bestelling == null) { return(HttpNotFound()); } ViewBag.klantid = new SelectList(db.klants, "klantid", "voorletters", bestelling.klantid); ViewBag.medewerkerid = new SelectList(db.medewerkers, "medewerkerid", "voorletters", bestelling.medewerkerid); ViewBag.statusid = new SelectList(db.status, "statusid", "status1", bestelling.statusid); ViewBag.vestigingid = new SelectList(db.vestigings, "vestigingsid", "vestigingsnaam", bestelling.vestigingid); return(View(bestelling)); }
public ActionResult TakeConfirmed(int?id) { //Get user id var user = User.Identity.GetUserId(); //Get current medewerker user var CurrentMedewerker = db.medewerkers.Where(m => m.AspNetUserID == user).FirstOrDefault(); //Find current bestelling bestelling bestelling = db.bestellings.Find(id); //Set employee that marked the bestelling as finished bestelling.medewerkerid = CurrentMedewerker.medewerkerid; //Set finished status bestelling.statusid = 3; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AnnulerenConfirmed(int?id) { bestelling bestelling = db.bestellings.Find(id); //Change status to canceled if not canceled or finished if (bestelling.statusid != 4 && bestelling.statusid != 3) { bestelling.statusid = 4; db.SaveChanges(); } else { return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
// GET: bestelling/Factuur/5 public ActionResult Factuur(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bestelling bestelling = db.bestellings.Find(id); if (bestelling == null) { return(HttpNotFound()); } PDFMaker PDFMaker = new PDFMaker(); byte[] abytes = PDFMaker.PreparePDF(bestelling); // Create pdf file from bestelling data return(File(abytes, "application/pdf")); }
// GET: PDF/PDF/5 public ActionResult PDF(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bestelling bestelling = db.bestellings.Find(id); if (bestelling == null) { return(HttpNotFound()); } //luuk sloopt alles PDFMaker PDFMaker = new PDFMaker(); byte[] abytes = PDFMaker.PreparePDF(bestelling); return(File(abytes, "application/pdf")); }
public StatusCodeResult Post([FromBody] Order order) { //Boolean to determine if order can be placed bool allProductsInStock = true; //Bestelling bestelling newBestelling = new bestelling(); newBestelling.datum = DateTime.Now.ToString(); newBestelling.prijs = 4.95; newBestelling.klantID = order.klantID; newBestelling.adres = order.adres; newBestelling.geregistreerd = order.geregistreerd; newBestelling.status = "Onbehandeld"; //Bestelling opbouwen uit aangeleverde json //Bestellingproduct krijgen wij binnen als array product ID's for (int i = 0; i < order.producten.Length; i++) { //Check of product in voorraad is. product Product = _context.product.Find(order.producten[i]); bool productInVoorraad = (Product.voorraad > 0) ? true : false; if (productInVoorraad) { //Product voorraad met 1 verminderen Product.voorraad -= 1; //bestellingproduct relatie opbouw: bestellingproduct productCombinatie = new bestellingproduct(); productCombinatie.productID = order.producten[i]; productCombinatie.bestellingID = newBestelling.ID; productCombinatie.product = Product; productCombinatie.bestelling = newBestelling; productCombinatie.verkoopPrijs = _context.product.Find(order.producten[i]).prijs; _context.bestellingproduct.Add(productCombinatie); newBestelling.producten.Append(productCombinatie); newBestelling.prijs = (newBestelling.prijs + productCombinatie.verkoopPrijs); } else { allProductsInStock = false; } } if (allProductsInStock) { try { _context.bestelling.Add(newBestelling); _context.SaveChanges(); return(Ok()); } catch { return(BadRequest()); } } else { return(StatusCode(410)); //Een van de producten niet in voorrraad } }
public ActionResult AfhalenConfirmed(int?id) { var user = User.Identity.GetUserId(); var CurrentMedewerker = db.medewerkers.Where(m => m.AspNetUserID == user).FirstOrDefault(); bestelling bestelling = db.bestellings.Find(id); var klant = db.klants.Where(k => k.klantid == bestelling.klantid).FirstOrDefault(); bestelling.medewerkerid = CurrentMedewerker.medewerkerid; bestelling.statusid = 2; db.SaveChanges(); // verzend een email var gebruikerd = from i in db.bestellings where i.bestellingid == bestelling.bestellingid select i; try { string gebruiker = User.Identity.Name; SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Port = 587; client.EnableSsl = true; //If you need to authenticate client.Credentials = new NetworkCredential("*****@*****.**", "Flowerpower!123"); MailMessage mailMessage = new MailMessage(); MailAddress mailAddress = new MailAddress("*****@*****.**"); mailMessage.From = mailAddress; mailMessage.To.Add(klant.AspNetUser.Email); mailMessage.Subject = "Bevestiging boeking " + bestelling.bestellingid; mailMessage.Body = "Beste " + gebruikerd.FirstOrDefault().klant.voorletters + " " + gebruikerd.FirstOrDefault().klant.achternaam + ",\n\n" + "Hartelijk dank voor uw bestelling bij flowerpower. Wij willen doormiddel van deze mail u informeren dat u uw bestelling kunt ophalen.\n" + "Hieronder hebben we uw bestellingsdetails:\n\n" + "" + "besteldatum: " + bestelling.besteldatum.ToString() + "\n" + "ophaaldatum: " + bestelling.ophaaldatum.ToString() + "\n" + "ophaal locatie: " + bestelling.vestiging.vestigingsadres + " ," + bestelling.vestiging.vestigingsplaats + " ," + bestelling.vestiging.vestigingspostcode + "\n" + "\n" + "Wij hopen hiermee u voldoende geinformeerd te hebben.\n\n\n" + "" + "" + "Met vriendelijke groet,\n\n" + "" + "" + "Flower Power"; client.Send(mailMessage); } catch (Exception ex) { } return(RedirectToAction("Index")); }