Prechádzať zdrojové kódy

CHG Réduction de la liste déroulate des années scolaires

olivier.massot 7 rokov pred
rodič
commit
18c46ee5c6

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

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Data.Entity;
+using System.Linq.Expressions;
 
 namespace CD67.FicheCollege.Factory
 {
@@ -45,15 +46,6 @@ namespace CD67.FicheCollege.Factory
             return dbContext.Annees.Where(a => a.Libelle == annee_lib).First().Id;
         }
 
-        public List<Annee> getFlatList()
-        {
-            List<Annee> annees = new List<Annee>();
-            foreach (Annee annee in dbContext.Annees)
-            {
-                annees.Add(annee.flat());
-            }
-            return annees;
-        }
 
     }
 }

+ 13 - 1
CD67.FicheCollege.MVC/Controllers/AnneesController.cs

@@ -86,7 +86,19 @@ namespace CD67.FicheCollege.MVC.Controllers
         public JsonResult GetList()
         {
             AnneeFactory fact = new AnneeFactory(db);
-            JsonResult res = Json(fact.getFlatList());
+
+            List<Annee> annees = new List<Annee>();
+            int max_id = 0;
+
+            foreach (Annee annee in fact.getManyBy(a => a.Colleges.Count > 0))
+            {
+                annees.Add(annee.flat());
+                if (annee.Id > max_id) { max_id = annee.Id; }
+            }
+            annees.Add(fact.getById(max_id + 1).flat());
+            annees.Add(fact.getById(max_id + 2).flat());
+
+            JsonResult res = Json(annees);
             res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
             return res;
         }