|
@@ -2,7 +2,9 @@
|
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc;
|
|
|
using CD67.ModeleMVC.Entity;
|
|
using CD67.ModeleMVC.Entity;
|
|
|
using CD67.ModeleMVC.Factory;
|
|
using CD67.ModeleMVC.Factory;
|
|
|
-
|
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
+using System;
|
|
|
|
|
+using System.Linq;
|
|
|
|
|
|
|
|
namespace CD67.ModeleMVC.MVC.Controllers
|
|
namespace CD67.ModeleMVC.MVC.Controllers
|
|
|
{
|
|
{
|
|
@@ -52,7 +54,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
|
|
|
// plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
// plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
|
[HttpPost]
|
|
[HttpPost]
|
|
|
[ValidateAntiForgeryToken]
|
|
[ValidateAntiForgeryToken]
|
|
|
- public ActionResult Create([Bind(Include = "ID,NOM,ID_TYPE,DESCRIPTION,DATE_INUTILE")] EXEMPLE_VIKINGS viking)
|
|
|
|
|
|
|
+ public ActionResult Create([Bind(Include = "ID,NOM,ID_TYPE,ID_SOUS_TYPE,DESCRIPTION,DATE_INUTILE")] EXEMPLE_VIKINGS viking)
|
|
|
{
|
|
{
|
|
|
if (ModelState.IsValid)
|
|
if (ModelState.IsValid)
|
|
|
{
|
|
{
|
|
@@ -86,7 +88,7 @@ namespace CD67.ModeleMVC.MVC.Controllers
|
|
|
// plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
// plus de détails, voir http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
|
[HttpPost]
|
|
[HttpPost]
|
|
|
[ValidateAntiForgeryToken]
|
|
[ValidateAntiForgeryToken]
|
|
|
- public ActionResult Edit([Bind(Include = "ID,NOM,ID_TYPE,DESCRIPTION,DATE_INUTILE")] EXEMPLE_VIKINGS viking)
|
|
|
|
|
|
|
+ public ActionResult Edit([Bind(Include = "ID,NOM,ID_TYPE,ID_SOUS_TYPE,DESCRIPTION,DATE_INUTILE")] EXEMPLE_VIKINGS viking)
|
|
|
{
|
|
{
|
|
|
if (ModelState.IsValid)
|
|
if (ModelState.IsValid)
|
|
|
{
|
|
{
|
|
@@ -138,6 +140,29 @@ namespace CD67.ModeleMVC.MVC.Controllers
|
|
|
{
|
|
{
|
|
|
TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
|
|
TYPE_VIKINGFactory typeVikingFactory = new TYPE_VIKINGFactory(db);
|
|
|
ViewBag.ID_TYPE = new SelectList(typeVikingFactory.getAll(), "ID", "TYPE", viking.ID_TYPE);
|
|
ViewBag.ID_TYPE = new SelectList(typeVikingFactory.getAll(), "ID", "TYPE", viking.ID_TYPE);
|
|
|
|
|
+
|
|
|
|
|
+ //Chargement d'une liste vide à la création
|
|
|
|
|
+ SOUS_TYPE_VIKINGFactory sousTypeFactory = new SOUS_TYPE_VIKINGFactory(db);
|
|
|
|
|
+ ViewBag.ID_SOUS_TYPE = new SelectList(sousTypeFactory.getManyBy(viking.ID_TYPE).OrderBy(i => i.Value), "Key", "Value", viking.ID_SOUS_TYPE);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //Mise à jour Ajax de la liste imbriquée
|
|
|
|
|
+ public JsonResult listeSousType(int Id, int? defaultSelected)
|
|
|
|
|
+ {
|
|
|
|
|
+ SOUS_TYPE_VIKINGFactory sousTypeFactory = new SOUS_TYPE_VIKINGFactory(db);
|
|
|
|
|
+ List<SelectListItem> listType = new List<SelectListItem>();
|
|
|
|
|
+
|
|
|
|
|
+ Dictionary<int, string> infoType = sousTypeFactory.getManyBy(Id); //le dictionnaire doit devenir une liste de types
|
|
|
|
|
+
|
|
|
|
|
+ List<Tuple<int, string>> listeType = new List<Tuple<int, string>>();
|
|
|
|
|
+ foreach (var type in infoType)
|
|
|
|
|
+ listeType.Add(new Tuple<int, string>(int.Parse(type.Key.ToString()), type.Value));
|
|
|
|
|
+
|
|
|
|
|
+ foreach (Tuple<int, string> liste in listeType)
|
|
|
|
|
+ listType.Add(new SelectListItem { Text = liste.Item2, Value = liste.Item1.ToString() });
|
|
|
|
|
+
|
|
|
|
|
+ return Json(new SelectList(listType, "Value", "Text", defaultSelected), JsonRequestBehavior.AllowGet);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|