olivier.massot 7 роки тому
батько
коміт
f62b3ab6f1

+ 2 - 1
CD67.FicheCollege.Factory/AnneeFactory.cs

@@ -7,8 +7,9 @@ using System.Data.Entity;
 
 namespace CD67.FicheCollege.Factory
 {
-    public partial class ActionCLASFactory : Internal.BaseFactory<Entity.ActionCLAS>
+    public partial class AnneeFactory : Internal.BaseFactory<Entity.Annee>
     {
+        public AnneeFactory(Entities dbContext) : base(dbContext) { }
 
     }
 }

+ 3 - 0
CD67.FicheCollege.MVC/CD67.FicheCollege.MVC.csproj

@@ -160,6 +160,7 @@
     <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\CollegesController.cs" />
     <Compile Include="Controllers\GestionActionsController.cs" />
+    <Compile Include="Controllers\AnneesController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\IdentitesController.cs" />
     <Compile Include="Controllers\TerritoireController.cs" />
@@ -172,6 +173,7 @@
     <Compile Include="Internal\MvcHtmlHelpers.cs" />
     <Compile Include="Internal\Navigation.cs" />
     <Compile Include="Internal\UtilisateurConnecteFactory.cs" />
+    <Compile Include="Models\TopModel.cs" />
     <Compile Include="Models\CollegeViewModel.cs" />
     <Compile Include="Models\ContactViewModel.cs" />
     <Compile Include="Models\ModeAcces.cs" />
@@ -392,6 +394,7 @@
     <Content Include="Views\ActionsCLAS\Details.cshtml" />
     <Content Include="Views\ActionsCLAS\Edit.cshtml" />
     <Content Include="Views\GestionActions\Index.cshtml" />
+    <Content Include="Views\Annees\Details.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />

+ 6 - 4
CD67.FicheCollege.MVC/Controllers/ActionsCLASController.cs

@@ -63,13 +63,15 @@ namespace CD67.FicheCollege.MVC.Controllers
             return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
         }
 
-        private Models.CollegeViewModel GetViewModel(Entity.ActionCLAS entity, Models.ModeAcces Acces)
+        private Models.CollegeViewModel GetViewModel(Entity.ActionCLAS action, Models.ModeAcces Acces)
         {
             return new Models.CollegeViewModel()
             {
-                College_Id = entity.College.Id,
-                College_Libelle = entity.College.Libelle,
-                Contenu = entity,
+                College_Id = action.College.Id,
+                //CodeRne = action.College.CodeRne,
+                //Annee_Id = action.College.Annee_Id,
+                College_Libelle = action.College.Libelle,
+                Contenu = action,
                 Acces = Acces,
                 Listes = null
             };

+ 2 - 2
CD67.FicheCollege.MVC/Controllers/AnneesController.cs

@@ -25,8 +25,8 @@ namespace CD67.FicheCollege.MVC.Controllers
                 return HttpNotFound();
             }
 
-            TopModel viewModel = new TopModel(annee);
-            return View(viewModel);
+            TopModel model = new TopModel(annee);
+            return View(model);
         }
     }
 }

+ 47 - 39
CD67.FicheCollege.MVC/Controllers/CollegesController.cs

@@ -8,6 +8,8 @@ using System.Web;
 using System.Web.Mvc;
 using CD67.FicheCollege.Entity;
 using CD67.FicheCollege.Factory;
+using CD67.FicheCollege.MVC.Models;
+using CD67.FicheCollege.MVC.Internal;
 
 namespace CD67.FicheCollege.MVC.Controllers
 {
@@ -16,10 +18,14 @@ namespace CD67.FicheCollege.MVC.Controllers
         private Entities db = new Entities();
 
         // GET: College
-        public ActionResult Index()
+        public ActionResult Index(int? annee_id)
         {
-            CollegeFactory collegeFactory = new CollegeFactory(db);
-            return View(collegeFactory.getAll());
+            if (annee_id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            TopModel model = new TopModel(db.Colleges.Where(c=>c.Annee_Id == annee_id), ModeAcces.Lecture);
+            return View(model);
         }
 
         // GET: College/Details/5
@@ -35,14 +41,22 @@ namespace CD67.FicheCollege.MVC.Controllers
             {
                 return HttpNotFound();
             }
-            return View(GetViewModel(college, Models.ModeAcces.Lecture));
+
+            TopModel model = new TopModel(college, ModeAcces.Lecture);
+
+            return View(model);
         }
 
         // GET: College/Create
         public ActionResult Create()
         {
             Entity.College college = new Entity.College();
-            return View("Edit", GetViewModel(college, Models.ModeAcces.Creation));
+
+            TopModel model = new TopModel(college, ModeAcces.Creation);
+            model.Bag["Select_TypeCollege"] = new SelectList(db.TypesCollege.OrderBy(t=>t.Ordre).ToList());
+            model.Bag["Select_CodePostaux"] = new SelectList(Referentiel.GetCodesPostaux(college.Commune_Insee));
+
+            return View("Edit", model);
         }
 
         // POST: College/Create
@@ -50,16 +64,20 @@ namespace CD67.FicheCollege.MVC.Controllers
         // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public ActionResult Create(Entity.College Contenu, string commentaire)
+        public ActionResult Create(Entity.College college, string commentaire)
         {
             if (ModelState.IsValid)
             {
                 CollegeFactory collegeFactory = new CollegeFactory(db);
-                collegeFactory.add(ref Contenu);
+                collegeFactory.add(ref college);
                 return RedirectToAction("Index");
             }
 
-            return View("Edit", GetViewModel(Contenu, Models.ModeAcces.Creation));
+            TopModel model = new TopModel(college, ModeAcces.Creation);
+            model.Bag["Select_TypeCollege"] = new SelectList(db.TypesCollege.ToList(), college.TypeCollege_Id);
+            model.Bag["Select_CodePostaux"] = new SelectList(Referentiel.GetCodesPostaux(college.Commune_Insee), college.Commune_Insee);
+
+            return View("Edit", model);
         }
 
         // GET: College/Edit/5
@@ -71,7 +89,12 @@ namespace CD67.FicheCollege.MVC.Controllers
             {
                 return HttpNotFound();
             }
-            return View(GetViewModel(college, Models.ModeAcces.Modification));
+
+            TopModel model = new TopModel(college, ModeAcces.Modification);
+            model.Bag["Select_TypeCollege"] = new SelectList(db.TypesCollege.ToList(), college.TypeCollege_Id);
+            model.Bag["Select_CodePostaux"] = new SelectList(Referentiel.GetCodesPostaux(college.Commune_Insee), college.Commune_Insee);
+
+            return View(model);
         }
 
         // POST: College/Edit/5
@@ -79,15 +102,20 @@ namespace CD67.FicheCollege.MVC.Controllers
         // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public ActionResult Edit(Entity.College Contenu)
+        public ActionResult Edit(Entity.College college)
         {
             if (ModelState.IsValid)
             {
                 CollegeFactory collegeFactory = new CollegeFactory(db);
-                collegeFactory.update(ref Contenu);
-                return RedirectToAction("Details", new { Id = Contenu.Id });
+                collegeFactory.update(ref college);
+                return RedirectToAction("Details", new { Id = college.Id });
             }
-            return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
+
+            TopModel model = new TopModel(college, ModeAcces.Modification);
+            model.Bag["Select_TypeCollege"] = new SelectList(db.TypesCollege.ToList(), college.TypeCollege_Id);
+            model.Bag["Select_CodePostaux"] = new SelectList(Referentiel.GetCodesPostaux(college.Commune_Insee), college.Commune_Insee);
+
+            return View(model);
         }
 
         // GET: College/Delete/5
@@ -103,7 +131,12 @@ namespace CD67.FicheCollege.MVC.Controllers
             {
                 return HttpNotFound();
             }
-            return View("Details", GetViewModel(college, Models.ModeAcces.Suppression));
+
+            TopModel model = new TopModel(college, ModeAcces.Suppression);
+            model.Bag["Select_TypeCollege"] = new SelectList(db.TypesCollege.ToList(), college.TypeCollege_Id);
+            model.Bag["Select_CodePostaux"] = new SelectList(Referentiel.GetCodesPostaux(college.Commune_Insee), college.Commune_Insee);
+
+            return View("Details", model);
         }
 
         // POST: College/Delete/5
@@ -117,31 +150,6 @@ namespace CD67.FicheCollege.MVC.Controllers
             return RedirectToAction("Index");
         }
 
-        private Models.CollegeViewModel GetViewModel(Entity.College entity, Models.ModeAcces Acces)
-        {
-            Dictionary<string, SelectList> listes = new Dictionary<string, SelectList>();
-
-            //On prépare les listes de choix en création ou modification
-            if (Acces == Models.ModeAcces.Creation || Acces == Models.ModeAcces.Modification)
-            {
-                TypeCollegeFactory typeCollegeFactory = new TypeCollegeFactory(db);
-                SelectList listeTypeCollege = new SelectList(typeCollegeFactory.getAll("Ordre"), "Id", "Libelle", entity.TypeCollege_Id);
-                listes.Add("TypeCollege_Id", listeTypeCollege);
-
-                SelectList listeCodesPostaux = new SelectList(Internal.Referentiel.GetCodesPostaux(entity.Commune_Insee), entity.Code_Postal);
-                listes.Add("Code_Postal", listeCodesPostaux);
-            }
-
-            return new Models.CollegeViewModel()
-            {
-                College_Id = entity.Id,
-                College_Libelle = entity.Libelle,
-                Contenu = entity,
-                Acces = Acces,
-                Listes = listes
-            };
-        }
-
         protected override void Dispose(bool disposing)
         {
             if (disposing)

+ 2 - 2
CD67.FicheCollege.MVC/Models/CollegeViewModel.cs

@@ -9,9 +9,9 @@ namespace CD67.FicheCollege.MVC.Models
     public class CollegeViewModel
     {
         public int College_Id { get; set; }
-        public int CodeRne { get; set; }
-        public int Annee_Id { get; set; }
         public string College_Libelle { get; set; }
+        public int Annee_Id { get; set; }
+        public string Annee_Lib { get; set; }
         public object Contenu { get; set; }
         public ModeAcces Acces { get; set; }
         public Dictionary<String, SelectList> Listes { get; set; }

+ 19 - 2
CD67.FicheCollege.MVC/Models/TopModel.cs

@@ -1,9 +1,10 @@
 using CD67.FicheCollege.Entity;
 using System.Collections.Generic;
+using System.Web.Mvc;
 
 namespace CD67.FicheCollege.MVC.Models
 {
-    // Wrapper du modele qui permet d'emmener des informations suppelementaires avec celui-ci.
+    // Wrapper du modele qui permet d'emmener des informations supplementaires avec celui-ci.
     public class TopModel
     {
         // Modele de la page en cours
@@ -34,7 +35,7 @@ namespace CD67.FicheCollege.MVC.Models
                 Bag = bag;
         }
 
-        // Constructeur particuliers
+        // Constructeurs particuliers
         public TopModel(Annee model,
             ModeAcces acces = ModeAcces.Lecture,
             Dictionary<string, object> bag = null)
@@ -43,8 +44,24 @@ namespace CD67.FicheCollege.MVC.Models
             Acces = acces;
             if (bag != null)
                 Bag = bag;
+
             Bag["Annee_Lib"] = model.Libelle;
         }
 
+        public TopModel(College model,
+            ModeAcces acces = ModeAcces.Lecture,
+            Dictionary<string, object> bag = null)
+        {
+            Model = model;
+            Acces = acces;
+            if (bag != null)
+                Bag = bag;
+
+            Bag["Annee_Lib"] = model.Annee.Libelle;
+        }
+
+
+
+
     }
 }

+ 4 - 3
CD67.FicheCollege.MVC/Views/Annees/Details.cshtml

@@ -6,10 +6,11 @@
 @{
     ViewBag.Title = "Fiches Collèges " + @Model.Bag["Annee_Lib"];
     Layout = "~/Views/Shared/_Layout.cshtml";
+    Annee annee = (Model.Obj as Annee);
 }
 
-<h1>Accueil @(Model.Obj.Libelle)</h1>
+<h1>Accueil @(annee.Libelle)</h1>
 
-@Html.ActionLink("Les collèges", "Index", "Colleges")<br />
-@Html.ActionLink("Les actions éducatives, sportives et culturelles", "Index", "Colleges")<br />
+@Html.ActionLink("Les collèges", "Index", "Colleges", new { annee_id = annee.Id }, null)<br />
+@Html.ActionLink("Les actions éducatives, sportives et culturelles", "Index", "Colleges", new { annee_id = annee.Id }, null)<br />
 @Html.ActionLink("La page d'administration du site", "Index", "Admin")<br />

+ 24 - 25
CD67.FicheCollege.MVC/Views/Colleges/Details.cshtml

@@ -1,15 +1,14 @@
 @using CD67.FicheCollege.MVC.Models
-@model CollegeViewModel
+@model TopModel
 
 @{
     ViewBag.Title = "Details";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    College contenu = Model.Contenu as College;
+    College college = (Model.Obj as College);
 }
 
 <h1>
-    Informations générales
-    <br /><span>du @Model.College_Libelle</span>
+    Informations générales <br/><span>du @college.Libelle</span>
 </h1>
 
 @if(Model.Acces==ModeAcces.Suppression) {
@@ -25,58 +24,58 @@
         @if (Model.Acces == ModeAcces.Lecture)
         {
             <div class="pull-right">
-                @Html.ActionLink("Supprimer", "Delete", "Colleges", new { Id = Model.College_Id }, new { @class = "btn btn-danger" })
-                @Html.ActionLink("Modifier", "Edit", "Colleges", new { Id = Model.College_Id }, new { @class = "btn btn-default" })
+                @Html.ActionLink("Supprimer", "Delete", "Colleges", new { Id = college.Id }, new { @class = "btn btn-danger" })
+                @Html.ActionLink("Modifier", "Edit", "Colleges", new { Id = college.Id }, new { @class = "btn btn-default" })
             </div>
         }
     </legend>
     <dl class="dl-horizontal">
         <dt>
-            @Html.DisplayNameFor(model => contenu.TypeCollege.Libelle)
+            @Html.DisplayNameFor(model => college.TypeCollege.Libelle)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.TypeCollege.Libelle)
+            @Html.DisplayFor(model => college.TypeCollege.Libelle)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Adresse)
+            @Html.DisplayNameFor(model => college.Adresse)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.AdresseComplete)
+            @Html.DisplayFor(model => college.AdresseComplete)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Tel)
+            @Html.DisplayNameFor(model => college.Tel)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.Tel)
+            @Html.DisplayFor(model => college.Tel)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Fax)
+            @Html.DisplayNameFor(model => college.Fax)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.Fax)
+            @Html.DisplayFor(model => college.Fax)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Email)
+            @Html.DisplayNameFor(model => college.Email)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.Email)
+            @Html.DisplayFor(model => college.Email)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Commune)
+            @Html.DisplayNameFor(model => college.Commune)
         </dt>
 
         <dd>
-            @if (contenu.Commune != null)
+            @if (Model.Obj.Commune != null)
             {
                 <div class="col-sm-8 col-md-4">
                     <div class="panel panel-default">
@@ -87,10 +86,10 @@
                             </h4>
                         </div>
                         <div class="panel-body" style="text-align: center;">
-                            <span style="white-space: pre-line;"><b>@contenu.Commune</b>
-                                Canton : @contenu.Canton
-                                TAD : @contenu.TAD
-                                CDC : @contenu.CDC
+                            <span style="white-space: pre-line;"><b>@college.Commune</b>
+                                Canton : @college.Canton
+                                TAD : @college.TAD
+                                CDC : @college.CDC
                             </span>
                         </div>
                     </div>
@@ -99,11 +98,11 @@
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => contenu.Code_Postal)
+            @Html.DisplayNameFor(model => college.Code_Postal)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => contenu.Code_Postal)
+            @Html.DisplayFor(model => college.Code_Postal)
         </dd>
     </dl>
 </fieldset>
@@ -116,7 +115,7 @@
 
         <div class="form-actions no-color">
             <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-danger" /> |
-            @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id })
+            @Html.ActionLink("Annuler", "Details", new { Id = college.Id })
         </div>
     }
 }

+ 44 - 44
CD67.FicheCollege.MVC/Views/Colleges/Edit.cshtml

@@ -1,13 +1,13 @@
 @using CD67.FicheCollege.MVC.Models
-@model CollegeViewModel
+@model TopModel
 
 @{
     ViewBag.Title = "Ajout";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    College contenu = Model.Contenu as College;
+    College college = (Model.Obj as College);
 }
 
-<h1>@Model.College_Libelle</h1>
+<h1>@college.Libelle</h1>
 
 @using (Html.BeginForm())
 {
@@ -24,59 +24,59 @@
 
             @if (Model.Acces == ModeAcces.Modification)
             {
-                @Html.HiddenFor(model => contenu.Id)
+                @Html.HiddenFor(model => college.Id)
             }
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Id, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.CodeRne, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
                     @if (Model.Acces == ModeAcces.Modification)
                     {
-                        @Html.EditorFor(model => contenu.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
+                        @Html.EditorFor(model => college.CodeRne, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
                     }
                     else
                     {
-                        @Html.EditorFor(model => contenu.Id, new { htmlAttributes = new { @class = "form-control" } })
+                        @Html.EditorFor(model => college.CodeRne, new { htmlAttributes = new { @class = "form-control" } })
                     }
-                    @Html.ValidationMessageFor(model => contenu.Id, "", new { @class = "text-danger" })
+                    @Html.ValidationMessageFor(model => college.CodeRne, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.EditorFor(model => contenu.Libelle, new { htmlAttributes = new { @class = "form-control" } })
-                    @Html.ValidationMessageFor(model => contenu.Libelle, "", new { @class = "text-danger" })
+                    @Html.EditorFor(model => college.Libelle, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => college.Libelle, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.TypeCollege_Id, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.DropDownListFor(model => contenu.TypeCollege_Id, Model.Listes["TypeCollege_Id"], htmlAttributes: new { @class = "form-control" })
-                    @Html.ValidationMessageFor(model => contenu.TypeCollege_Id, "", new { @class = "text-danger" })
+                    @Html.DropDownListFor(model => college.TypeCollege_Id, (Model.Bag["Select_TypeCollege"] as IEnumerable<SelectListItem>), htmlAttributes: new { @class = "form-control" })
+                    @Html.ValidationMessageFor(model => college.TypeCollege_Id, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Adresse, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.EditorFor(model => contenu.Adresse, new { htmlAttributes = new { @class = "form-control" } })
-                    @Html.ValidationMessageFor(model => contenu.Adresse, "", new { @class = "text-danger" })
+                    @Html.EditorFor(model => college.Adresse, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => college.Adresse, "", new { @class = "text-danger" })
                 </div>
             </div>
 
-            @Html.HiddenFor(model => contenu.Commune_Insee, new { data_picker = "commune.insee" })
-            @Html.HiddenFor(model => contenu.Commune, new { data_picker = "commune.nom" })
-            @Html.HiddenFor(model => contenu.Canton, new { data_picker = "commune.canton" })
-            @Html.HiddenFor(model => contenu.Territoire_Id, new { data_picker = "commune.code_tad" })
-            @Html.HiddenFor(model => contenu.TAD, new { data_picker = "commune.tad" })
-            @Html.HiddenFor(model => contenu.CDC, new { data_picker = "commune.cdc" })
+            @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
+            @Html.HiddenFor(model => college.Commune, new { data_picker = "commune.nom" })
+            @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
+            @Html.HiddenFor(model => college.Territoire_Id, new { data_picker = "commune.code_tad" })
+            @Html.HiddenFor(model => college.TAD, new { data_picker = "commune.tad" })
+            @Html.HiddenFor(model => college.CDC, new { data_picker = "commune.cdc" })
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
+                @Html.LabelFor(model => college.Commune, htmlAttributes: new { @class = "control-label col-md-2 required" })
                 <div class="col-md-4">
                     <a class='modal-window-events' href="http://referentiel.bas-rhin.fr/picker/cd67/com67/" title="Selection commune (nouvelle fenetre)">Sélectionner une commune</a>
                     <br />
-                    <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (contenu.Commune_Insee == null) { <text>display: none;</text> }">
+                    <div class="panel panel-default" id="Commune_Panel" name="Commune_Panel" style="@if (college.Commune_Insee == null) { <text>display: none;</text> }">
                         <div class="panel-heading clearfix">
                             <h4 class="panel-title pull-left" style="padding-top: 7.5px;">
                                 <i class="fa fa-map-marker color1" aria-hidden="true"></i>
@@ -88,48 +88,48 @@
                         </div>
                         <div class="panel-body" style="text-align: center;">
                             <span>
-                                <b><span data-picker="commune.nom">@contenu.Commune</span ></b >
-                                <br />Canton : <span data-picker="commune.canton">@contenu.Canton</span >
-                                <br />TAD : <span data-picker="commune.tad">@contenu.TAD</span >
-                                <br />CDC : <span data-picker="commune.cdc">@contenu.CDC</span >
+                                <b><span data-picker="commune.nom">@college.Commune</span ></b >
+                                <br />Canton : <span data-picker="commune.canton">@college.Canton</span >
+                                <br />TAD : <span data-picker="commune.tad">@college.TAD</span >
+                                <br />CDC : <span data-picker="commune.cdc">@college.CDC</span >
                             </span>
                         </div>
                     </div>
-                    @Html.ValidationMessageFor(model => contenu.Commune, "", new { @class = "text-danger" })
+                    @Html.ValidationMessageFor(model => college.Commune, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Code_Postal, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Code_Postal, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    Code(s) postal(aux) associé(s) à la commune <span id="CP-warning" class="text-danger" style="@if (Model.Listes["Code_Postal"].Count() == 1) { <text>display: none;</text> }">(attention, plusieurs choix possibles)</span> : <input id="code_postaux" data-picker="commune.code_postal" value="@String.Join(",", Model.Listes["Code_Postal"].Select(i => i.Text))" class="disabled-input-as-label" />
+                    Code(s) postal(aux) associé(s) à la commune <span id="CP-warning" class="text-danger" style="@if ((Model.Bag["Select_CodePostaux"] as IEnumerable<SelectListItem>).Count() == 1) { <text>display: none;</text> }">(attention, plusieurs choix possibles)</span> : <input id="code_postaux" data-picker="commune.code_postal" value="@String.Join(",", (Model.Bag["Select_CodePostaux"] as IEnumerable<SelectListItem>).Select(i => i.Text))" class="disabled-input-as-label" />
                     <br />
-                    @Html.DropDownListFor(model => contenu.Code_Postal, Model.Listes["Code_Postal"], htmlAttributes: new { @class = "form-control" })
-                    @Html.ValidationMessageFor(model => contenu.Code_Postal, "", new { @class = "text-danger" })
+                    @Html.DropDownListFor(model => college.Code_Postal, (Model.Bag["Select_CodePostaux"] as IEnumerable<SelectListItem>), htmlAttributes: new { @class = "form-control" })
+                    @Html.ValidationMessageFor(model => college.Code_Postal, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Tel, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.EditorFor(model => contenu.Tel, new { htmlAttributes = new { @class = "form-control" } })
-                    @Html.ValidationMessageFor(model => contenu.Tel, "", new { @class = "text-danger" })
+                    @Html.EditorFor(model => college.Tel, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => college.Tel, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Fax, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.EditorFor(model => contenu.Fax, new { htmlAttributes = new { @class = "form-control" } })
-                    @Html.ValidationMessageFor(model => contenu.Fax, "", new { @class = "text-danger" })
+                    @Html.EditorFor(model => college.Fax, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => college.Fax, "", new { @class = "text-danger" })
                 </div>
             </div>
 
             <div class="form-group">
-                @Html.LabelFor(model => contenu.Email, htmlAttributes: new { @class = "control-label col-md-2" })
+                @Html.LabelFor(model => college.Email, htmlAttributes: new { @class = "control-label col-md-2" })
                 <div class="col-md-10">
-                    @Html.EditorFor(model => contenu.Email, new { htmlAttributes = new { @class = "form-control" } })
-                    @Html.ValidationMessageFor(model => contenu.Email, "", new { @class = "text-danger" })
+                    @Html.EditorFor(model => college.Email, new { htmlAttributes = new { @class = "form-control" } })
+                    @Html.ValidationMessageFor(model => college.Email, "", new { @class = "text-danger" })
                 </div>
             </div>
 
@@ -139,7 +139,7 @@
                     @if (Model.Acces == ModeAcces.Creation)
                     { @Html.ActionLink("Annuler", "Index") }
                     else
-                    { @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id }) }
+                    { @Html.ActionLink("Annuler", "Details", new { Id = college.Id }) }
                 </div>
             </div>
         </div>

+ 15 - 12
CD67.FicheCollege.MVC/Views/Colleges/Index.cshtml

@@ -1,8 +1,11 @@
-@model IEnumerable<CD67.FicheCollege.Entity.College>
+@using CD67.FicheCollege.MVC.Models
+@model TopModel
+@*IEnumerable<CD67.FicheCollege.Entity.College>*@
 
 @{
     ViewBag.Title = "Liste";
     Layout = "~/Views/Shared/_Layout.cshtml";
+    IEnumerable<CD67.FicheCollege.Entity.College> colleges = Model.Obj;
 }
 
 <h2>Index</h2>
@@ -17,38 +20,38 @@
 <table class="table">
     <tr>
         <th>
-            @Html.DisplayNameFor(model => model.Id)
+            @Html.DisplayNameFor(model => (model.Obj as College).Id)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Libelle)
+            @Html.DisplayNameFor(model => (model.Obj as College).Libelle)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Adresse)
+            @Html.DisplayNameFor(model => (model.Obj as College).Adresse)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.CDC)
+            @Html.DisplayNameFor(model => (model.Obj as College).CDC)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Tel)
+            @Html.DisplayNameFor(model => (model.Obj as College).Tel)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Fax)
+            @Html.DisplayNameFor(model => (model.Obj as College).Fax)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Email)
+            @Html.DisplayNameFor(model => (model.Obj as College).Email)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.Territoire.Libelle)
+            @Html.DisplayNameFor(model => (model.Obj as College).Territoire.Libelle)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.TypeCollege.Libelle)
+            @Html.DisplayNameFor(model => (model.Obj as College).TypeCollege.Libelle)
         </th>
     </tr>
 
-@foreach (var item in Model) {
+@foreach (College item in Model.Obj) {
     <tr>
         <td>
-            @Html.ActionLink(item.Id, "Details", new { id = item.Id })
+            @Html.ActionLink(item.CodeRne.ToString(), "Details", new { id = item.Id })
         </td>
         <td>
             @Html.DisplayFor(modelItem => item.Libelle)

+ 7 - 2
CD67.FicheCollege.MVC/Views/Shared/_Layout.cshtml

@@ -8,13 +8,18 @@
     string url = Request.Url.ToString();
 
     bool editionCollege = false;
-    string college_Id = null;
+    int? college_Id = null;
     string college_Libelle = null;
+    int? annee_Id = null;
+    string annee_Libelle = null;
+
     if (Model is CollegeViewModel && Model.College_Id != null)
     {
         editionCollege = true;
         college_Id = (Model as CollegeViewModel).College_Id;
         college_Libelle = (Model as CollegeViewModel).College_Libelle;
+        annee_Id = (Model as CollegeViewModel).Annee_Id;
+        annee_Libelle = (Model as CollegeViewModel).Annee_Lib;
     }
 }
 <!DOCTYPE html>
@@ -51,7 +56,7 @@
             <div id="topbar" class="navbar navbar-inner">
                 <div id="open-button" class="menu-button"><span>Menu invisible</span></div>
                 <ul id="titre" class="nav navbar ">
-                    <li><h1 id="app-title">Fiches collège</h1></li>
+                    <li><h1 id="app-title">Fiches collège @annee_Libelle</h1></li>
                 </ul>
                 <ul class="nav navbar-nav navbar-right">
                     <li class="search">