فهرست منبع

get_current_year_id() deplacé vers la Factory

olivier.massot 7 سال پیش
والد
کامیت
9af5a08495

+ 0 - 14
CD67.FicheCollege.Entity/Extend/Annee.cs

@@ -10,20 +10,6 @@ namespace CD67.FicheCollege.Entity
     [MetadataType(typeof(Annee_Metadata))]
     public partial class Annee
     {
-        public static int get_current_year_id()
-        {
-            Entities db = new Entities();
-            string annee_lib;
-            if (DateTime.Now.Month <= 7)
-            {
-                annee_lib = String.Format("{0}-{1}", DateTime.Now.Year - 1, DateTime.Now.Year);
-            }
-            else
-            {
-                annee_lib = String.Format("{0}-{1}", DateTime.Now.Year, DateTime.Now.Year + 1);
-            }
-            return db.Annees.Where(a => a.Libelle == annee_lib).First().Id;
-        }
     }
 
     /// <summary>

+ 1 - 6
CD67.FicheCollege.Entity/Extend/College.cs

@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.ComponentModel.DataAnnotations;
 
 namespace CD67.FicheCollege.Entity
 {

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

@@ -9,7 +9,7 @@ namespace CD67.FicheCollege.Factory
 {
     public partial class AnneeFactory : Internal.BaseFactory<Entity.Annee>
     {
-        public AnneeFactory(Entities dbContext) : base(dbContext) { }
+        //public AnneeFactory(Entities dbContext) : base(dbContext) { }
 
         public Annee getByLibelle(params object[] keyValues)
         {
@@ -30,5 +30,20 @@ namespace CD67.FicheCollege.Factory
             return annee;
         }
 
+        // Retourne l'id de l'année courante
+        public int get_current_year_id()
+        {
+            string annee_lib;
+            if (DateTime.Now.Month <= 7)
+            {
+                annee_lib = String.Format("{0}-{1}", DateTime.Now.Year - 1, DateTime.Now.Year);
+            }
+            else
+            {
+                annee_lib = String.Format("{0}-{1}", DateTime.Now.Year, DateTime.Now.Year + 1);
+            }
+            return dbContext.Annees.Where(a => a.Libelle == annee_lib).First().Id;
+        }
+
     }
 }

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

@@ -61,6 +61,9 @@
     <Compile Include="Internal\ActionCLASFactory.cs">
       <DependentUpon>GenericFactories.tt</DependentUpon>
     </Compile>
+    <Compile Include="Internal\AnneeFactory.cs">
+      <DependentUpon>GenericFactories.tt</DependentUpon>
+    </Compile>
     <Compile Include="Internal\CollegeFactory.cs">
       <DependentUpon>GenericFactories.tt</DependentUpon>
     </Compile>

+ 21 - 0
CD67.FicheCollege.Factory/Internal/AnneeFactory.cs

@@ -0,0 +1,21 @@
+using CD67.FicheCollege.Entity;
+using System.Linq;
+
+namespace CD67.FicheCollege.Factory
+{
+	/// <summary>
+    /// NE PAS MODIFIER
+    /// C'est une classe partielle, elle peut être complétée avec une classe partielle du même nom
+    /// Factory générée automatiquement à l'aide du fichier GenericFactories.tt
+    /// pour toutes les entités du fichier entity : /CD67.FicheCollege.Entity/EntityModel.edmx
+    /// </summary>
+	public partial class AnneeFactory : Internal.BaseFactory<Entity.Annee>
+	{
+		/// <summary>
+        /// Constructeur public lié au constructeur de base
+        /// </summary>
+        /// <param name="dbContext">Context Entity Framework utilisé dans la classe</param>
+		public AnneeFactory(Entities dbContext) : base(dbContext) { }
+	}
+}
+