public ActionResult Create([Bind(Include = "Label,Description,DateCreation,Statut,CategorieID")] Annonce annonce) { if (ModelState.IsValid) { db.Annonces.Add(annonce); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategorieID = new SelectList(db.Categories, "ID", "Nom", annonce.CategorieID); return(View(annonce)); }
public ActionResult Ajouter(Categorie model) { if (ModelState.IsValid) { //enregistrement en base _db.Categories.Add(model); _db.SaveChanges(); return(RedirectToAction("index")); } else { return(View()); } }