Kaynağa Gözat

CHG Restauration des pages d'administration collèges

olivier.massot 7 yıl önce
ebeveyn
işleme
c34f04b5ac

+ 1 - 2
CD67.FicheCollege.MVC/CD67.FicheCollege.MVC.csproj

@@ -160,7 +160,6 @@
     <Compile Include="Controllers\ActionsEduCollegeController.cs" />
     <Compile Include="Controllers\ActionsEduController.cs" />
     <Compile Include="Controllers\ActionEduThematiquesController.cs" />
-    <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\CollegesController.cs" />
     <Compile Include="Controllers\GestionActionsController.cs" />
     <Compile Include="Controllers\AnneesController.cs" />
@@ -178,6 +177,7 @@
     <Compile Include="Internal\UtilisateurConnecteFactory.cs" />
     <Compile Include="Models\ActionEduAxeViewModel.cs" />
     <Compile Include="Models\ActionEduThematiqueViewModel.cs" />
+    <Compile Include="Models\TerritoireViewModel.cs" />
     <Compile Include="Models\TypeCollegeViewModel.cs" />
     <Compile Include="Models\ActionEduViewModel.cs" />
     <Compile Include="Models\IdentiteViewModel.cs" />
@@ -385,7 +385,6 @@
     <Content Include="Views\Shared\DisplayTemplates\Date.cshtml" />
     <Content Include="Views\Shared\EditorTemplates\Date.cshtml" />
     <Content Include="Views\Shared\_Flash.cshtml" />
-    <Content Include="Views\Admin\Index.cshtml" />
     <Content Include="Views\TypeCollege\Create.cshtml" />
     <Content Include="Views\TypeCollege\Delete.cshtml" />
     <Content Include="Views\TypeCollege\Edit.cshtml" />

+ 0 - 17
CD67.FicheCollege.MVC/Controllers/AdminController.cs

@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
-
-namespace CD67.FicheCollege.MVC.Controllers
-{
-    public class AdminController : Controller
-    {
-        // GET: Admin
-        public ActionResult Index()
-        {
-            return View();
-        }
-    }
-}

+ 22 - 15
CD67.FicheCollege.MVC/Controllers/TerritoireController.cs

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

+ 27 - 0
CD67.FicheCollege.MVC/Models/TerritoireViewModel.cs

@@ -0,0 +1,27 @@
+using CD67.FicheCollege.Entity;
+using CD67.FicheCollege.Factory;
+using CD67.FicheCollege.MVC.Internal;
+using System.Collections.Generic;
+using System.Web.Mvc;
+
+namespace CD67.FicheCollege.MVC.Models
+{
+    public class TerritoireViewModel : BaseViewModel<Territoire>
+    {
+        public TerritoireViewModel(Territoire model, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
+        {
+        }
+
+        public override string Annee_Lib { get { return ""; } }
+    }
+
+    public class TerritoireIndexViewModel : BaseViewModel<IEnumerable<Territoire>>
+    {
+        public TerritoireIndexViewModel(IEnumerable<Territoire> model, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
+        {
+        }
+
+        public override string Annee_Lib { get { return ""; } }
+
+    }
+}

+ 0 - 12
CD67.FicheCollege.MVC/Views/Admin/Index.cshtml

@@ -1,12 +0,0 @@
-
-@{
-    ViewBag.Title = "Administration";
-    Layout = "~/Views/Shared/_Layout.cshtml";
-}
-
-<h2>Listes de choix</h2>
-
-<hr />
-
-@Html.ActionLink("Administration des types de collège", "Index", "TypeCollege")<br />
-@Html.ActionLink("Administration des territoires", "Index", "Territoire")<br />

+ 0 - 1
CD67.FicheCollege.MVC/Views/Annees/Details.cshtml

@@ -13,5 +13,4 @@
 <ul>
     <li>@Html.ActionLink("Les collèges", "Index", "Colleges", new { annee_id = Model.Obj.Id }, null)</li>
     <li>@Html.ActionLink("Les actions", "Index", "ActionsEduCollege", new { annee_id = Model.Obj.Id }, null)</li>
-    <li>@Html.ActionLink("Administration", "Index", "Admin", new { annee_id = Model.Obj.Id }, null)</li>
 </ul>

+ 6 - 1
CD67.FicheCollege.MVC/Views/Colleges/Index.cshtml

@@ -7,7 +7,7 @@
     College college_model = new College();
 }
 
-<h2>Index</h2>
+<h2>Les collèges @Model.Annee_Lib</h2>
 
 <p>
     <a href="@Url.Action("Create", new { annee_id = Model.Obj.Id })">
@@ -80,3 +80,8 @@
 }
 
 </table>
+
+<h3>Administation</h3>
+
+@Html.ActionLink("Types de collège", "Index", "TypeCollege")<br />
+@Html.ActionLink("Territoires", "Index", "Territoire")<br />

+ 19 - 17
CD67.FicheCollege.MVC/Views/Territoire/Create.cshtml

@@ -1,8 +1,10 @@
-@model CD67.FicheCollege.Entity.Territoire
+@using CD67.FicheCollege.MVC.Models
+@model TerritoireViewModel
 
 @{
     ViewBag.Title = "Création";
     Layout = "~/Views/Shared/_Layout.cshtml";
+    Territoire territoire = Model.Obj;
 }
 
 <h2>Création</h2>
@@ -16,36 +18,36 @@
         <h4>Territoire</h4>
         <hr />
         @Html.ValidationSummary(true, "", new { @class = "text-danger" })
-        @Html.HiddenFor(model => model.Ordre)
+        @Html.HiddenFor(model => territoire.Ordre)
 
         <div class="form-group">
-            @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
+            @Html.LabelFor(model => territoire.Id, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
-                @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control", @autofocus = true } })
-                @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
+                @Html.EditorFor(model => territoire.Id, new { htmlAttributes = new { @class = "form-control", @autofocus = true } })
+                @Html.ValidationMessageFor(model => territoire.Id, "", new { @class = "text-danger" })
             </div>
         </div>
 
         <div class="form-group">
-            @Html.LabelFor(model => model.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
+            @Html.LabelFor(model => territoire.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
-                @Html.EditorFor(model => model.Libelle, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => model.Libelle, "", new { @class = "text-danger" })
+                @Html.EditorFor(model => territoire.Libelle, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => territoire.Libelle, "", new { @class = "text-danger" })
             </div>
         </div>
 
         <div class="form-group">
             @Html.Label("Référent", htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-4" data-picker-type="referent">
-                @Html.HiddenFor(model => model.Referent_SID, new { data_picker = "agent.id" })
-                @Html.HiddenFor(model => model.Referent_Nom, new { data_picker = "agent.nom" })
-                @Html.HiddenFor(model => model.Referent_Prenom, new { data_picker = "agent.prenom" })
-                @Html.HiddenFor(model => model.Referent_Structure, new { data_picker = "agent.chemin" })
-                @Html.HiddenFor(model => model.Referent_Login, new { data_picker = "agent.login" })
-                @Html.HiddenFor(model => model.Referent_Email, new { data_picker = "agent.mail" })
+                @Html.HiddenFor(model => territoire.Referent_SID, new { data_picker = "agent.id" })
+                @Html.HiddenFor(model => territoire.Referent_Nom, new { data_picker = "agent.nom" })
+                @Html.HiddenFor(model => territoire.Referent_Prenom, new { data_picker = "agent.prenom" })
+                @Html.HiddenFor(model => territoire.Referent_Structure, new { data_picker = "agent.chemin" })
+                @Html.HiddenFor(model => territoire.Referent_Login, new { data_picker = "agent.login" })
+                @Html.HiddenFor(model => territoire.Referent_Email, new { data_picker = "agent.mail" })
                 <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=referent" title="Selection d'un référent (nouvelle fenetre)">Sélectionner un référent</a>
                 <br />
-                <div class="panel panel-default" id="Referent_Panel" name="Referent_Panel" style="@if (Model.Referent_SID == null) { <text>display: none;</text> }">
+                <div class="panel panel-default" id="Referent_Panel" name="Referent_Panel" style="@if (territoire.Referent_SID == 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-user color1" aria-hidden="true"></i>
@@ -56,8 +58,8 @@
                         </div>
                     </div>
                     <div class="panel-body" style="text-align: center;">
-                        <b><span data-picker="agent.prenom">@Model.Referent_Prenom</span> <span data-picker="agent.nom">@Model.Referent_Nom</span></b>
-                        <br /><span data-picker="agent.chemin">@Model.Referent_Structure</span>
+                        <b><span data-picker="agent.prenom">@territoire.Referent_Prenom</span> <span data-picker="agent.nom">@territoire.Referent_Nom</span></b>
+                        <br /><span data-picker="agent.chemin">@territoire.Referent_Structure</span>
                     </div>
                 </div>
             </div>

+ 5 - 21
CD67.FicheCollege.MVC/Views/Territoire/Delete.cshtml

@@ -1,8 +1,9 @@
-@model CD67.FicheCollege.Entity.Territoire
-
+@using CD67.FicheCollege.MVC.Models
+@model TerritoireViewModel
 @{
     ViewBag.Title = "Suppression";
     Layout = "~/Views/Shared/_Layout.cshtml";
+    Territoire territoire = Model.Obj;
 }
 
 <h2>Suppression</h2>
@@ -13,27 +14,10 @@
     <hr />
     <dl class="dl-horizontal">
         <dt>
-            @Html.DisplayNameFor(model => model.Id)
-        </dt>
-
-        <dd>
-            @Html.DisplayFor(model => model.Id)
-        </dd>
-
-        <dt>
-            @Html.DisplayNameFor(model => model.Libelle)
+            @Html.DisplayNameFor(model => territoire.Libelle)
         </dt>
-
-        <dd>
-            @Html.DisplayFor(model => model.Libelle)
-        </dd>
-
-        <dt>
-            @Html.DisplayNameFor(model => model.Referent)
-        </dt>
-
         <dd>
-            @Html.DisplayFor(model => model.Referent)
+            @Html.DisplayFor(model => territoire.Libelle)
         </dd>
     </dl>
 

+ 20 - 18
CD67.FicheCollege.MVC/Views/Territoire/Edit.cshtml

@@ -1,8 +1,10 @@
-@model CD67.FicheCollege.Entity.Territoire
+@using CD67.FicheCollege.MVC.Models
+@model TerritoireViewModel
 
 @{
     ViewBag.Title = "Modification";
     Layout = "~/Views/Shared/_Layout.cshtml";
+    Territoire territoire = Model.Obj;
 }
 
 <h2>Modification</h2>
@@ -16,37 +18,37 @@
         <h4>Territoire</h4>
         <hr />
         @Html.ValidationSummary(true, "", new { @class = "text-danger" })
-        @Html.HiddenFor(model => model.Id)
-        @Html.HiddenFor(model => model.Ordre)
+        @Html.HiddenFor(model => territoire.Id)
+        @Html.HiddenFor(model => territoire.Ordre)
 
         <div class="form-group">
-            @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
+            @Html.LabelFor(model => territoire.Id, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
-                @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
-                @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
+                @Html.EditorFor(model => territoire.Id, new { htmlAttributes = new { @class = "form-control", @disabled = true } })
+                @Html.ValidationMessageFor(model => territoire.Id, "", new { @class = "text-danger" })
             </div>
         </div>
 
         <div class="form-group">
-            @Html.LabelFor(model => model.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
+            @Html.LabelFor(model => territoire.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
-                @Html.EditorFor(model => model.Libelle, new { htmlAttributes = new { @class = "form-control" } })
-                @Html.ValidationMessageFor(model => model.Libelle, "", new { @class = "text-danger" })
+                @Html.EditorFor(model => territoire.Libelle, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => territoire.Libelle, "", new { @class = "text-danger" })
             </div>
         </div>
 
         <div class="form-group">
             @Html.Label("Référent", htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-4" data-picker-type="referent">
-                @Html.HiddenFor(model => model.Referent_SID, new { data_picker = "agent.id" })
-                @Html.HiddenFor(model => model.Referent_Nom, new { data_picker = "agent.nom" })
-                @Html.HiddenFor(model => model.Referent_Prenom, new { data_picker = "agent.prenom" })
-                @Html.HiddenFor(model => model.Referent_Structure, new { data_picker = "agent.chemin" })
-                @Html.HiddenFor(model => model.Referent_Login, new { data_picker = "agent.login" })
-                @Html.HiddenFor(model => model.Referent_Email, new { data_picker = "agent.mail" })
+                @Html.HiddenFor(model => territoire.Referent_SID, new { data_picker = "agent.id" })
+                @Html.HiddenFor(model => territoire.Referent_Nom, new { data_picker = "agent.nom" })
+                @Html.HiddenFor(model => territoire.Referent_Prenom, new { data_picker = "agent.prenom" })
+                @Html.HiddenFor(model => territoire.Referent_Structure, new { data_picker = "agent.chemin" })
+                @Html.HiddenFor(model => territoire.Referent_Login, new { data_picker = "agent.login" })
+                @Html.HiddenFor(model => territoire.Referent_Email, new { data_picker = "agent.mail" })
                 <a class='modal-window' href="http://referentiel.bas-rhin.fr/picker/cd67/ad67/?type=referent" title="Selection d'un référent (nouvelle fenetre)">Sélectionner un référent</a>
                 <br />
-                <div class="panel panel-default" id="Referent_Panel" name="Referent_Panel" style="@if (Model.Referent_SID == null) { <text>display: none;</text> }">
+                <div class="panel panel-default" id="Referent_Panel" name="Referent_Panel" style="@if (territoire.Referent_SID == 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-user color1" aria-hidden="true"></i>
@@ -57,8 +59,8 @@
                         </div>
                     </div>
                     <div class="panel-body" style="text-align: center;">
-                        <b><span data-picker="agent.prenom">@Model.Referent_Prenom</span> <span data-picker="agent.nom">@Model.Referent_Nom</span></b>
-                        <br /><span data-picker="agent.chemin">@Model.Referent_Structure</span>
+                        <b><span data-picker="agent.prenom">@territoire.Referent_Prenom</span> <span data-picker="agent.nom">@territoire.Referent_Nom</span></b>
+                        <br /><span data-picker="agent.chemin">@territoire.Referent_Structure</span>
                     </div>
                 </div>
             </div>

+ 8 - 6
CD67.FicheCollege.MVC/Views/Territoire/Index.cshtml

@@ -1,10 +1,12 @@
-@model IEnumerable<CD67.FicheCollege.Entity.Territoire>
+@using CD67.FicheCollege.MVC.Models
+@model TerritoireIndexViewModel
 
 @{
     ViewBag.Title = "Liste";
     Layout = "~/Views/Shared/_Layout.cshtml";
-    int maxOrdre = Model.Count() == 0 ? 0 : Model.Max(i => i.Ordre);
+    int maxOrdre = Model.Obj.Count() == 0 ? 0 : Model.Obj.Max(i => i.Ordre);
     int row = 1;
+    Territoire modele_territoire = new Territoire();
 }
 
 <h2>Liste</h2>
@@ -18,13 +20,13 @@
 
 <table class="table">
     <tr>
-        <th>@Html.DisplayNameFor(model => model.Id)</th>
-        <th>@Html.DisplayNameFor(model => model.Libelle)</th>
-        <th>@Html.DisplayNameFor(model => model.Referent)</th>
+        <th>@Html.DisplayNameFor(model => modele_territoire.Id)</th>
+        <th>@Html.DisplayNameFor(model => modele_territoire.Libelle)</th>
+        <th>@Html.DisplayNameFor(model => modele_territoire.Referent)</th>
         <th></th>
     </tr>
 
-@foreach (var item in Model)
+@foreach (var item in Model.Obj.OrderBy(i=>i.Ordre))
 {
     <tr>
         <td>@Html.DisplayFor(modelItem => item.Id)</td>

+ 3 - 2
CD67.FicheCollege.MVC/Views/TypeCollege/Index.cshtml

@@ -6,6 +6,7 @@
     Layout = "~/Views/Shared/_Layout.cshtml";
     int maxOrdre = Model.Obj.Count() == 0 ? 0 : Model.Obj.Max(i => i.Ordre);
     int row = 1;
+    TypeCollege type_model = new TypeCollege();
 }
 
 <h2>Liste</h2>
@@ -20,12 +21,12 @@
 <table class="table">
     <tr>
         <th>
-            @*@Html.DisplayNameFor(model => model.Obj.Libelle)*@
+            @Html.DisplayNameFor(model => type_model.Libelle)
         </th>
         <th></th>
     </tr>
 
-    @foreach (var item in Model.Obj)
+    @foreach (var item in Model.Obj.OrderBy(i => i.Ordre))
     {
         <tr>
             <td>