Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Fabrikant fabrikant = db.FabrikantDbSet.Find(id); //verwijder de fabrikant met hetzelfde id als is meegegeven in de link

            db.FabrikantDbSet.Remove(fabrikant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "FabrikantId,Naam,Telefoonnummer")] Fabrikant fabrikant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fabrikant).State = EntityState.Modified;
         db.SaveChanges(); //slaat de fabrikant op met de aangepaste data
         return(RedirectToAction("Index"));
     }
     return(View(fabrikant));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "FabrikantId,Naam,Telefoonnummer")] Fabrikant fabrikant) //maakt een nieuwe Fabrikant aan mat FabrikantId, Naam, Telefoonnummer
        {
            if (ModelState.IsValid)
            {
                db.FabrikantDbSet.Add(fabrikant); //maakt een nieuwe Fabrikant aan mat FabrikantId, Naam, Telefoonnummer
                db.SaveChanges();                 //opslaan
                return(RedirectToAction("Index"));
            }

            return(View(fabrikant));
        }
Ejemplo n.º 4
0
        // GET: Fabrikant/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Fabrikant fabrikant = db.FabrikantDbSet.Find(id); //zoek de fabrikant met hetzelfde id als is meegegeven in de link

            if (fabrikant == null)
            {
                return(HttpNotFound());
            }
            return(View(fabrikant));
        }
Ejemplo n.º 5
0
        public ActionResult Create(ProductViewModel productViewModel)
        {
            Product newProduct = new Product(productViewModel.Naam, productViewModel.Type, productViewModel.MinimaalAantal, productViewModel.InkoopPrijs, productViewModel.VerkoopPrijs); //maak een nieuw product aan
            ProductFabrikant_regel newProductFabrikantRegel = new ProductFabrikant_regel();                                                                                               //maak een nieuwe productfabrikanregel aan

            if (productViewModel.FabrikantId != null)
            {
                foreach (int item in productViewModel.FabrikantId)
                {
                    Fabrikant foundFabrikant = db.FabrikantDbSet.Find(item);
                    ProductFabrikant_regel productFabrikant = new ProductFabrikant_regel {
                        Fabrikant = foundFabrikant, Product = newProduct
                    };                                                 //de data die opgeslagen word in de productfabrikant regel
                    newProduct.ProductFabrikant.Add(productFabrikant); //voeg koppeltabel regel toe
                }

                db.ProductDbSet.Add(newProduct); //voeg het product toe
                db.SaveChanges();
            }
            return(this.RedirectToAction("Index"));
        }