Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductGroep productGroep = _db.ProductGroepen.Find(id);

            _db.ProductGroepen.Remove(productGroep);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        // GET: ProductGroepen/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductGroep productGroep = _db.ProductGroepen.Find(id);

            if (productGroep == null)
            {
                return(HttpNotFound());
            }
            return(View(productGroep));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,Nummer,Naam")] ProductGroep productGroep)
        {
            if (_db.ProductGroepen.Any(o => o.Nummer == productGroep.Nummer))
            {
                // Number is already used
                var mod = ModelState.First(c => c.Key == "Nummer");
                mod.Value.Errors.Add("Dit nummer is al in gebruik!");
            }

            if (!ModelState.IsValid)
            {
                // Model not valid!
                return(View(productGroep));
            }

            _db.ProductGroepen.Add(productGroep);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public ActionResult Edit([Bind(Include = "Id,Nummer,Naam")] ProductGroep productGroep)
        {
            if (_db.ProductGroepen.Any(o => o.Nummer == productGroep.Nummer && o.Id != productGroep.Id))
            {
                // Number is already used
                var mod = ModelState.First(c => c.Key == "Nummer");
                mod.Value.Errors.Add("Dit nummer is al in gebruik!");
            }

            if (!ModelState.IsValid)
            {
                // Model is not Valid
                return(View(productGroep));
            }

            _db.Entry(productGroep).State = EntityState.Modified;
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }