public ActionResult slettBestilling(int id, Bestilling slettBestilling)
 {
     var bestillingDb = new BestillingBLL();
     bool slettOk = bestillingDb.slettBestilling(id);
     if(slettOk)
     {
         return RedirectToAction("BestillingListe");
     }
     return View();
 }
 public ActionResult endreBestilling(int id, Bestilling endreBestilling)
 {
     if(ModelState.IsValid)
     {
         var bestilling = new BestillingBLL();
         bool endringOk = bestilling.endreBestilling(id, endreBestilling);
         if(endringOk)
         {
             return RedirectToAction("BestillingListe");
         }
     }
     return View();
 }
 public ActionResult RegistrerBestilling(Bestilling innBestilling)
 {
     if(ModelState.IsValid)
     {
         var bestilling = new BestillingBLL();
         bool insertOk = bestilling.leggTilBestilling(innBestilling);
         if(insertOk)
         {
             return RedirectToAction("BestillingListe");
         }
     }
     return View();
 }
 public bool leggTilBestilling(Bestilling innBestilling)
 {
     using (var context = new ButikkContext())
     {
         var bestilling = new Bestilling()
         {
             OrdreDato = innBestilling.OrdreDato,
             Total = innBestilling.Total,
             Varer = innBestilling.Varer
         };
         context.Bestillinger.Add(bestilling);
         var saved = context.SaveChanges();
         return saved >= 1;
     }
 }
        public bool endreBestilling(int id, Bestilling bestilling)
        {
            var db = new ButikkContext();

            try
            {
                Bestilling endreBestilling = db.Bestillinger.Find(id);
                endreBestilling.OrdreDato = bestilling.OrdreDato;
                endreBestilling.Total = bestilling.Total;
                endreBestilling.Varer = bestilling.Varer;

                db.SaveChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
        public Bestilling hentEnBestilling(int id)
        {
            var db = new ButikkContext();
            var enDbBestilling = db.Bestillinger.Find(id);

            if(enDbBestilling == null)
            {
                return null;
            }
            else
            {
                var utBestilling = new Bestilling()
                {
                    OrdreDato = enDbBestilling.OrdreDato,
                    Total = enDbBestilling.Total,
                    Varer = enDbBestilling.Varer
                };
                return utBestilling;
            }
        }
 public bool leggTilBestilling(Bestilling innBestilling)
 {
     var BestillingDAL = new BestillingDAL();
     return BestillingDAL.leggTilBestilling(innBestilling);
 }
 public bool endreBestilling(int id, Bestilling innBestilling)
 {
     var BestillingDAL = new BestillingDAL();
     return BestillingDAL.endreBestilling(id, innBestilling);
 }