public ActionResult Edit(int key) { int materialKey = (int)key; var materialDB = new MaterialDB(); var cvDB = new CvDB(); MaterialModel material = materialDB.GetMaterialByKey(materialKey); material.MaterialTypeSelectList = new SelectList(cvDB.GetMaterialTypes(), "_MaterialType_key", "MaterialType"); return View(material); }
public ActionResult Create() { try { var cvDB = new CvDB(); ViewBag._MaterialType_key = new SelectList(cvDB.GetMaterialTypes(), "_MaterialType_key", "MaterialType"); return View(); } catch (Exception ex) { Response.Write(ex.Message); return View() ; } }
public ActionResult Create(MaterialModel material) { try { var materialDB = new MaterialDB(); var cvDB=new CvDB(); material.MaterialTypeSelectList = new SelectList(cvDB.GetMaterialTypes(),"_MaterialType_key", "MaterialType"); materialDB.Create(material); return RedirectToAction("Index"); } catch { return View(); } }