public ActionResult Edit(int id, FormCollection collection) { Code c = repo.GetCode(id); CodeFormViewModel v = new CodeFormViewModel(c); try { UpdateModel(c); repo.Save(); return RedirectToAction("Index"); } catch (System.Data.SqlClient.SqlException ) { ModelState.AddModelError("ProjectID", "Prosjektnummer finnes ikke"); return View(new CodeFormViewModel(c)); } catch { ModelState.AddRuleViolations(v.Code .GetRuleViolations()); return View(new CodeFormViewModel (c)); } }
// // GET: /Code/Edit/5 public ActionResult Edit(int id) { Code c = repo.GetCode(id); CodeFormViewModel v = new CodeFormViewModel(c); return View(v); }
// // GET: /Code/Create public ActionResult Create() { Code c = new Code(); CodeFormViewModel v = new CodeFormViewModel(c); return View(v); }