예제 #1
0
        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));
            }
        }
예제 #2
0
 //
 // GET: /Code/Edit/5
 public ActionResult Edit(int id)
 {
     Code c = repo.GetCode(id);
     CodeFormViewModel v = new CodeFormViewModel(c);
     return View(v);
 }
예제 #3
0
 //
 // GET: /Code/Create
 public ActionResult Create()
 {
     Code c =  new Code();
     CodeFormViewModel v = new CodeFormViewModel(c);
     return View(v);
 }