public ActionResult BestillVare(FormCollection innListe) { var BLL = new BLL.BestillingBLL(); int ordreid = BLL.bestillVare(Int32.Parse(innListe["kundeID"]), Int32.Parse(innListe["vareID"])); /*using (var db = new BestillingContext()) { int vareID = Int32.Parse(innListe["vareID"]); int kundeID = Int32.Parse(innListe["kundeID"]); Bestilling nyBestilling = new Bestilling(); nyBestilling.tid = DateTime.Now; Kunde k = db.Kunder.FirstOrDefault(kunde => kunde.kundeID == kundeID); nyBestilling.kundeID = k;//koble til kunde Vare v = db.Varer.FirstOrDefault(vare => vare.vareID == vareID); nyBestilling.vareID = v;//koble til vare db.Bestillinger.Add(nyBestilling); db.SaveChanges(); ordreid = nyBestilling.ordreID; }*/ return RedirectToAction("visKvitering", new { ordreid }); //return View(); }
public ActionResult BestillVare(FormCollection innListe) { var BLL = new BLL.BestillingBLL(); int ordreid = BLL.bestillVare(Int32.Parse(innListe["kundeID"]), Int32.Parse(innListe["vareID"])); /*using (var db = new BestillingContext()) * { * int vareID = Int32.Parse(innListe["vareID"]); * int kundeID = Int32.Parse(innListe["kundeID"]); * Bestilling nyBestilling = new Bestilling(); * nyBestilling.tid = DateTime.Now; * Kunde k = db.Kunder.FirstOrDefault(kunde => kunde.kundeID == kundeID); * nyBestilling.kundeID = k;//koble til kunde * Vare v = db.Varer.FirstOrDefault(vare => vare.vareID == vareID); * nyBestilling.vareID = v;//koble til vare * db.Bestillinger.Add(nyBestilling); * db.SaveChanges(); * * ordreid = nyBestilling.ordreID; * }*/ return(RedirectToAction("visKvitering", new { ordreid })); //return View(); } //trykket på Bestill