public ActionResult Edit([Bind(Include = "modelID,name,brandID,characteristics,description,type")] tech_models tech_model) { if (ModelState.IsValid) { db.Entry(tech_model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.brandID = new SelectList(db.tech_brands, "brandID", "name", tech_model.brandID); return(View(tech_model)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tech_models tech_model = db.tech_models.Find(id); if (tech_model == null) { return(HttpNotFound()); } return(View(tech_model)); }
public ActionResult DeleteConfirmed(int id) { tech_models tech_model = db.tech_models.Find(id); db.tech_models.Remove(tech_model); IEnumerable <equipment> equipment = db.equipments.Where(e => e.modelID == id); foreach (equipment e in equipment) { e.modelID = null; } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tech_models tech_model = db.tech_models.Find(id); if (tech_model == null) { return(HttpNotFound()); } var tech_brands = db.tech_brands.Where(tb => tb.brandID != null).ToList(); IEnumerable <SelectListItem> selectList = from tb in tech_brands select new SelectListItem { Value = tb.brandID.ToString(), Text = tb.name }; ViewBag.brandID = new SelectList(selectList, "Value", "Text", tech_model.brandID); return(View(tech_model)); }