public ActionResult OpprettKunde(FormCollection innListe)
        {
            try
            {
                using (var db = new BestillingContext())
                {
                    var nyKunde = new Kunde();
                    nyKunde.fornavn = innListe["Fornavn"];
                    nyKunde.etternavn = innListe["Etternavn"];
                    nyKunde.adresse = innListe["Adresse"];
                    nyKunde.email = innListe["Email"];
                    nyKunde.postnr = innListe["Postnr"];
                    nyKunde.poststed = innListe["Poststed"];
                    nyKunde.passord = innListe["Passord"];

                    db.Kunder.Add(nyKunde);
                    db.SaveChanges();
                    return View();//RedirectToAction("ListAlleBrukere");
                }
            }
            catch (Exception feil)
            {
                return View();
            }
        }
 public ActionResult BestillVare(int vareid = 0)
 {
     var db = new BestillingContext();
      Vare vare = db.Varer.Find(vareid);
      if (vare == null)
      {
          return HttpNotFound();
      }
      return View(vare);
 }
        public ActionResult BestillVare(FormCollection innListe)
        {
            int ordreid;
             using (var db = new BestillingContext())
             {
                 int vareID = Int32.Parse(innListe["VId"]);
                 int kundeID = Int32.Parse(innListe["KId"]);
                 Bestilling nyBestilling = new Bestilling();

                 Kunde k = db.Kunder.FirstOrDefault(kunde => kunde.KId == kundeID);
                 nyBestilling.KId = k;
                 Vare v = db.Varer.FirstOrDefault(vare => vare.VId == vareID);
                 nyBestilling.VId = v;
                 db.Bestillinger.Add(nyBestilling);
                 db.SaveChanges();

                 ordreid = nyBestilling.orderID;
             }

             return View();
        }
 public ActionResult ListAlleKunder()
 {
     var db = new BestillingContext();
     List<Kunde> listeAvKunder = db.Kunder.ToList();
     return View(listeAvKunder);
 }