EmployeController.cs 760 B

12345678910111213141516171819202122232425262728
  1. using AppliWebANA.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. namespace AppliWebANA.Controllers {
  8. public class EmployeController : Controller {
  9. [HttpGet]
  10. public ActionResult Index() {
  11. ViewBag.Poste = string.Empty; // Pour éviter la pré-sélection de la 1ere valeur de l'énum (car Employe.Poste n'est un pas annulable)
  12. return View();
  13. }
  14. [HttpPost, ValidateAntiForgeryToken]
  15. public ActionResult Index( Employe nv ) { // Model binding => remplit le ModelState
  16. if( !ModelState.IsValid ) {
  17. return View(); // LEs TextBoxFOR lisent le ModelState
  18. }
  19. // ... Sauver ...
  20. ViewBag.Message = "OK, c'est sauvé !";
  21. ModelState.Clear();
  22. return View();
  23. }
  24. }
  25. }