public ActionResult Create(TacheFormCreate form) { try { if (!ModelState.IsValid) { throw new Exception("Formulaire non valide"); } if (form.Intitule == null) { throw new Exception(); } Tache data = new Tache() { Intitule = form.Intitule, Description = form.Description, AttributeTo = form.AttributeTo, CreationDate = DateTime.Now, IsDone = false }; int id = _service.Insert(data); return(RedirectToAction("Details", new { id = id })); } catch (Exception ex) { ViewBag.Notification = ex.Message; if (form.Intitule == null) { ModelState.AddModelError("Intitule", "Intitulé obligatoire"); } TacheFormCreate data = new TacheFormCreate(); return(View(data)); } }
// GET: Todo/Create public ActionResult Create() { TacheFormCreate data = new TacheFormCreate(); return(View(data)); }