Kaynağa Gözat

Integration de l'index des années (brut)

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

+ 1 - 0
CD67.FicheCollege.Entity/CD67.FicheCollege.Entity.csproj

@@ -130,6 +130,7 @@
       <DependentUpon>EntityModel.edmx</DependentUpon>
       <LastGenOutput>EntityModel.cs</LastGenOutput>
     </Content>
+    <Content Include="Model_initial_inserts.sql" />
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 3 - 2
CD67.FicheCollege.Entity/Extend/ActionCLAS.cs

@@ -20,8 +20,9 @@ namespace CD67.FicheCollege.Entity
     /// </summary>
     public class ActionCLAS_Metadata
     {
-        [UIHint("YesNoBool")]
-        public bool Action { get; set; }
+        //[UIHint("YesNoBool")]
+        public bool? Action { get; set; }
+
         [DataType(DataType.MultilineText)]
         public string Commentaire { get; set; }
     }

+ 19 - 0
CD67.FicheCollege.Factory/AnneeFactory.cs

@@ -11,5 +11,24 @@ namespace CD67.FicheCollege.Factory
     {
         public AnneeFactory(Entities dbContext) : base(dbContext) { }
 
+        public Annee getByLibelle(params object[] keyValues)
+        {
+            string libelle = keyValues[0].ToString();
+            
+            Annee annee = base.getAll().Where(a=>a.Libelle == libelle).First();
+            //si l'élément n'existe pas, on le créé
+            if (annee == null)
+            {
+                annee = new Annee()
+                {
+                    Libelle = libelle
+                };
+                this.add(ref annee);
+                dbContext.Entry(annee).Reference(i => i.Colleges).Load();
+            }
+
+            return annee;
+        }
+
     }
 }

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

@@ -393,6 +393,7 @@
     <Content Include="Views\ActionsCLAS\Edit.cshtml" />
     <Content Include="Views\GestionActions\Index.cshtml" />
     <Content Include="Views\Annees\Details.cshtml" />
+    <Content Include="Views\Annees\Index.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />

+ 0 - 1
CD67.FicheCollege.MVC/Controllers/ActionsCLASController.cs

@@ -65,7 +65,6 @@ namespace CD67.FicheCollege.MVC.Controllers
                 return RedirectToAction("Details", new { id = actionClas.College_Id });
             }
 
-            db.Entry(actionClas).Reference(i => i.College).Load();
             ActionClasViewModel model = new ActionClasViewModel(actionClas, ModeAcces.Modification);
             return View(model);
         }

+ 47 - 0
CD67.FicheCollege.MVC/Controllers/AnneesController.cs

@@ -3,6 +3,7 @@ using System.Net;
 using CD67.FicheCollege.Factory;
 using CD67.FicheCollege.Entity;
 using CD67.FicheCollege.MVC.Models;
+using System.Collections.Generic;
 
 namespace CD67.FicheCollege.MVC.Controllers
 {
@@ -10,6 +11,15 @@ namespace CD67.FicheCollege.MVC.Controllers
     {
         private Entities db = new Entities();
 
+        // GET: Annees
+        public ActionResult Index()
+        {
+            AnneeFactory fact = new AnneeFactory(db);
+
+            AnneeIndexViewModel model = new AnneeIndexViewModel(fact.getAll());
+            return View(model);
+        }
+
         // GET: Home
         public ActionResult Details(int? id)
         {
@@ -28,5 +38,42 @@ namespace CD67.FicheCollege.MVC.Controllers
             AnneeViewModel model = new AnneeViewModel(annee);
             return View(model);
         }
+
+        public ActionResult Previous(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+
+            AnneeFactory anneeFactory = new AnneeFactory(db);
+            Entity.Annee annee = anneeFactory.getById(id);
+            if (annee == null)
+            {
+                return HttpNotFound();
+            }
+
+            AnneeViewModel model = new AnneeViewModel(annee);
+            return View(model);
+        }
+
+        public ActionResult Next(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+
+            AnneeFactory anneeFactory = new AnneeFactory(db);
+            Entity.Annee annee = anneeFactory.getById(id);
+            if (annee == null)
+            {
+                return HttpNotFound();
+            }
+
+            AnneeViewModel model = new AnneeViewModel(annee);
+            return View(model);
+        }
+
     }
 }

+ 31 - 0
CD67.FicheCollege.MVC/Models/TopModel.cs

@@ -83,6 +83,37 @@ namespace CD67.FicheCollege.MVC.Models
         }
     }
 
+    public class AnneeIndexViewModel : TopModel
+    {
+        public AnneeIndexViewModel(object model, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
+        {
+        }
+
+        public IEnumerable<Annee> Obj
+        {
+            get
+            {
+                return (_Obj as IEnumerable<Annee>);
+            }
+        }
+
+        public override int Id
+        {
+            get
+            {
+                return 0;
+            }
+        }
+
+        public override string Annee_Lib
+        {
+            get
+            {
+                return "";
+            }
+        }
+    }
+
     public class CollegeViewModel : TopModel
     {
         public SelectList Sel_TypesCollege;

+ 17 - 0
CD67.FicheCollege.MVC/Views/Annees/Index.cshtml

@@ -0,0 +1,17 @@
+@using CD67.FicheCollege.MVC.Models
+@model AnneeIndexViewModel
+
+@{
+    ViewBag.Title = "Liste";
+}
+
+<h2>Années scolaires disponibles</h2>
+
+<ul>
+    @foreach (Annee annee in Model.Obj)
+    {
+        <li>
+            @Html.ActionLink(annee.Libelle, "Details", new { id = annee.Id })
+        </li>
+    }
+</ul>

+ 9 - 22
CD67.FicheCollege.MVC/Views/Shared/_Layout.cshtml

@@ -1,27 +1,14 @@
 @using CD67.FicheCollege.MVC.Models
 
 @{
+    string url = Request.Url.ToString();
     var controllerName = ViewContext.RouteData.Values["controller"].ToString();
     var actionName = ViewContext.RouteData.Values["action"].ToString();
+
     //Récupération de l'utilisateur connecté
     UtilisateurConnecte utilisateurConnecte = CD67.FicheCollege.MVC.Internal.UtilisateurConnecteFactory.getUtilisateurConnecte();
-    string url = Request.Url.ToString();
-
-    //bool editionCollege = false;
-    //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>
 <html lang="fr">
 <head>
@@ -56,7 +43,12 @@
             <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 @Model.Annee_Lib</h1></li>
+                    <li>
+                        <h1 id="app-title">Fiches collège @Model.Annee_Lib</h1>
+                    </li>
+                    <li>
+                        <a href="/Annees">Changer d'année scolaire</a>
+                    </li>
                 </ul>
                 <ul class="nav navbar-nav navbar-right">
                     <li class="search">
@@ -136,11 +128,6 @@
                 <li><a href="/">Accueil</a><span class="divider"></span></li>
                 <li><a>&gt;</a><span class="divider"></span></li>
                 <li>@Html.ActionLink("Collèges", "Index", "Colleges")</li>
-                @*@if (Model.Obj is College & Model.Acces == ModeAcces.Modification)
-                {
-                    <li><a>&gt;</a><span class="divider"></span></li>
-                    <li>@Html.ActionLink(String.Format("{0} {1}", Model.Obj.CodeRne, Model.Obj.Libelle), "Details", "Colleges", new { Id = Model.Obj.Id })</li>
-                }*@
             </ul>
             @*@Html.MvcSiteMap().SiteMapPath()*@
         </div>