|
@@ -2,6 +2,7 @@
|
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc;
|
|
|
using CD67.FicheCollege.Entity;
|
|
using CD67.FicheCollege.Entity;
|
|
|
using CD67.FicheCollege.Factory;
|
|
using CD67.FicheCollege.Factory;
|
|
|
|
|
+using CD67.FicheCollege.MVC.Models;
|
|
|
|
|
|
|
|
namespace CD67.FicheCollege.MVC.Controllers
|
|
namespace CD67.FicheCollege.MVC.Controllers
|
|
|
{
|
|
{
|
|
@@ -13,14 +14,16 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
public ActionResult Index()
|
|
public ActionResult Index()
|
|
|
{
|
|
{
|
|
|
TerritoireFactory territoireFactory = new TerritoireFactory(db);
|
|
TerritoireFactory territoireFactory = new TerritoireFactory(db);
|
|
|
- return View(territoireFactory.getAll());
|
|
|
|
|
|
|
+ TerritoireIndexViewModel model = new TerritoireIndexViewModel(territoireFactory.getAll());
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GET: Territoire/Create
|
|
// GET: Territoire/Create
|
|
|
public ActionResult Create()
|
|
public ActionResult Create()
|
|
|
{
|
|
{
|
|
|
Entity.Territoire territoire = new Entity.Territoire();
|
|
Entity.Territoire territoire = new Entity.Territoire();
|
|
|
- return View(territoire);
|
|
|
|
|
|
|
+ TerritoireViewModel model = new TerritoireViewModel(territoire);
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// POST: Territoire/Create
|
|
// POST: Territoire/Create
|
|
@@ -37,13 +40,14 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
return RedirectToAction("Index");
|
|
return RedirectToAction("Index");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return View(territoire);
|
|
|
|
|
|
|
+ TerritoireViewModel model = new TerritoireViewModel(territoire);
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GET: Territoire/Edit/5
|
|
// GET: Territoire/Edit/5
|
|
|
- public ActionResult Edit(int? id)
|
|
|
|
|
|
|
+ public ActionResult Edit(string id)
|
|
|
{
|
|
{
|
|
|
- if (id == null)
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(id))
|
|
|
{
|
|
{
|
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
}
|
|
}
|
|
@@ -53,7 +57,8 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
{
|
|
{
|
|
|
return HttpNotFound();
|
|
return HttpNotFound();
|
|
|
}
|
|
}
|
|
|
- return View(territoire);
|
|
|
|
|
|
|
+ TerritoireViewModel model = new TerritoireViewModel(territoire);
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// POST: Territoire/Edit/5
|
|
// POST: Territoire/Edit/5
|
|
@@ -69,13 +74,14 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
territoireFactory.update(ref territoire);
|
|
territoireFactory.update(ref territoire);
|
|
|
return RedirectToAction("Index");
|
|
return RedirectToAction("Index");
|
|
|
}
|
|
}
|
|
|
- return View(territoire);
|
|
|
|
|
|
|
+ TerritoireViewModel model = new TerritoireViewModel(territoire);
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GET: Territoire/Delete/5
|
|
// GET: Territoire/Delete/5
|
|
|
- public ActionResult Delete(int? id)
|
|
|
|
|
|
|
+ public ActionResult Delete(string id)
|
|
|
{
|
|
{
|
|
|
- if (id == null)
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(id))
|
|
|
{
|
|
{
|
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
}
|
|
}
|
|
@@ -85,13 +91,14 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
{
|
|
{
|
|
|
return HttpNotFound();
|
|
return HttpNotFound();
|
|
|
}
|
|
}
|
|
|
- return View(territoire);
|
|
|
|
|
|
|
+ TerritoireViewModel model = new TerritoireViewModel(territoire);
|
|
|
|
|
+ return View(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// POST: Territoire/Delete/5
|
|
// POST: Territoire/Delete/5
|
|
|
[HttpPost, ActionName("Delete")]
|
|
[HttpPost, ActionName("Delete")]
|
|
|
[ValidateAntiForgeryToken]
|
|
[ValidateAntiForgeryToken]
|
|
|
- public ActionResult DeleteConfirmed(int id)
|
|
|
|
|
|
|
+ public ActionResult DeleteConfirmed(string id)
|
|
|
{
|
|
{
|
|
|
TerritoireFactory territoireFactory = new TerritoireFactory(db);
|
|
TerritoireFactory territoireFactory = new TerritoireFactory(db);
|
|
|
Entity.Territoire territoire = territoireFactory.getById(id);
|
|
Entity.Territoire territoire = territoireFactory.getById(id);
|
|
@@ -99,9 +106,9 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
return RedirectToAction("Index");
|
|
return RedirectToAction("Index");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ActionResult Up(int? id)
|
|
|
|
|
|
|
+ public ActionResult Up(string id)
|
|
|
{
|
|
{
|
|
|
- if (id == null)
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(id))
|
|
|
{
|
|
{
|
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
}
|
|
}
|
|
@@ -111,9 +118,9 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
return RedirectToAction("Index");
|
|
return RedirectToAction("Index");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ActionResult Down(int? id)
|
|
|
|
|
|
|
+ public ActionResult Down(string id)
|
|
|
{
|
|
{
|
|
|
- if (id == null)
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(id))
|
|
|
{
|
|
{
|
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
}
|
|
}
|