Example #1
0
 public ActionResult Edit([Bind(Include = "brandID,name,description")] tech_brands tech_brand)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tech_brand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tech_brand));
 }
Example #2
0
        public ActionResult Create([Bind(Include = "brandID,name,description")] tech_brands tech_brand)
        {
            if (ModelState.IsValid)
            {
                db.tech_brands.Add(tech_brand);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tech_brand));
        }
Example #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tech_brands tech_brand = db.tech_brands.Find(id);

            if (tech_brand == null)
            {
                return(HttpNotFound());
            }
            return(View(tech_brand));
        }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            tech_brands tech_brand = db.tech_brands.Find(id);

            db.tech_brands.Remove(tech_brand);
            IEnumerable <tech_models> tech_models = db.tech_models.Where(tm => tm.brandID == id);

            foreach (tech_models tm in tech_models)
            {
                tm.brandID = null;
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }