Bon c'est juste un controlleurs je devellope en MVC donc je vais pas te mettre tout les fichier
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplicationDumb.Models;
namespace MvcApplicationDumb.Controllers
{
public class EventController : Controller
{
private EventDBContext db = new EventDBContext();
//
// GET: /Event/
public ViewResult Index()
{
return View(db.Event.ToList());
}
//
// GET: /Event/Details/5
public ViewResult Details(int id)
{
Event eventa = db.Event.Find(id);
return View(eventa);
}
//
// GET: /Event/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Event/Create
[HttpPost]
public ActionResult Create(Event eventa)
{
if (ModelState.IsValid)
{
db.Event.Add(eventa);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(eventa);
}
//
// GET: /Event/Edit/5
public ActionResult Edit(int id)
{
Event eventa = db.Event.Find(id);
return View(eventa);
}
//
// POST: /Event/Edit/5
[HttpPost]
public ActionResult Edit(Event eventa)
{
if (ModelState.IsValid)
{
db.Entry(eventa).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(eventa);
}
//
// GET: /Event/Delete/5
public ActionResult Delete(int id)
{
Event eventa = db.Event.Find(id);
return View(eventa);
}
//
// POST: /Event/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
Event eventa = db.Event.Find(id);
db.Event.Remove(eventa);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
public ActionResult SearchIndex(string searchString)
{
var Event = from m in db.Event
select m;
if (!String.IsNullOrEmpty(searchString))
{
Event = Event.Where(s => s.Name.Contains(searchString));
}
return View(Event);
}
}
}