Exemplo n.º 1
0
        public ActionResult Create(FormCollection collection)
        {
            Code  c = new Code();
            try
            {
                UpdateModel(c);
                repo.AddCode(c );
                repo.Save();

                return RedirectToAction("Index");
            }
            catch (System.Data.SqlClient.SqlException )
            {
                ModelState.AddModelError("ProjectID", "Prosjektnummer finnes ikke");
                return View(c);
            }

            catch
            {
                ModelState.AddRuleViolations(c .GetRuleViolations());
                return View(c);
            }
        }