Browse Source

NEW Actions educatives CRUD ok

olivier.massot 7 years ago
parent
commit
a962f80cae

+ 3 - 3
CD67.FicheCollege.BDD/dbo/Tables/ActionsEdu.sql

@@ -5,9 +5,9 @@
     [Neutralise]            BIT            NOT NULL,
     [Ordre]                 INT            NOT NULL,
     [ActionEduThematiqueId] INT            NOT NULL,
-    [Annee_Id]              INT            NOT NULL,
+    [AnneeId]               INT            NOT NULL,
     CONSTRAINT [PK_ActionsEdu] PRIMARY KEY CLUSTERED ([Id] ASC),
-    CONSTRAINT [FK_ActionEduAnnee] FOREIGN KEY ([Annee_Id]) REFERENCES [dbo].[Annees] ([Id]),
+    CONSTRAINT [FK_ActionEduAnnee] FOREIGN KEY ([AnneeId]) REFERENCES [dbo].[Annees] ([Id]),
     CONSTRAINT [FK_ActionEduThematiqueActionEdu] FOREIGN KEY ([ActionEduThematiqueId]) REFERENCES [dbo].[ActionEduThematiques] ([Id])
 );
 
@@ -19,5 +19,5 @@ CREATE NONCLUSTERED INDEX [IX_FK_ActionEduThematiqueActionEdu]
 
 GO
 CREATE NONCLUSTERED INDEX [IX_FK_ActionEduAnnee]
-    ON [dbo].[ActionsEdu]([Annee_Id] ASC);
+    ON [dbo].[ActionsEdu]([AnneeId] ASC);
 

+ 1 - 0
CD67.FicheCollege.Entity/ActionEdu.cs

@@ -20,6 +20,7 @@ namespace CD67.FicheCollege.Entity
         public bool Neutralise { get; set; }
         public int Ordre { get; set; }
         public int ActionEduThematiqueId { get; set; }
+        public int AnneeId { get; set; }
     
         public virtual ActionEduThematique ActionEduThematique { get; set; }
         public virtual Annee Annee { get; set; }

+ 16 - 14
CD67.FicheCollege.Entity/EntityModel.edmx

@@ -156,7 +156,7 @@
     <Property Name="Neutralise" Type="bit" Nullable="false" />
     <Property Name="Ordre" Type="int" Nullable="false" />
     <Property Name="ActionEduThematiqueId" Type="int" Nullable="false" />
-    <Property Name="Annee_Id" Type="int" Nullable="false" />
+    <Property Name="AnneeId" Type="int" Nullable="false" />
   </EntityType>
   <Association Name="FK_Colleges_Territoires">
     <End Role="Territoire" Type="CD67.FicheCollege.Store.Territoires" Multiplicity="0..1" />
@@ -238,7 +238,7 @@
         <PropertyRef Name="Id" />
       </Principal>
       <Dependent Role="ActionEdu">
-        <PropertyRef Name="Annee_Id" />
+        <PropertyRef Name="AnneeId" />
       </Dependent>
     </ReferentialConstraint>
   </Association>
@@ -430,7 +430,7 @@
             <PropertyRef Name="Id" />
           </Key>
           <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Nom" Type="String" Nullable="false" />
+          <Property Name="Nom" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="Neutralise" Type="Boolean" Nullable="false" DefaultValue="False" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
           <NavigationProperty Name="ActionEduThematiques" Relationship="CD67.FicheCollege.ActionEduAxeActionEduThematique" FromRole="ActionEduAxe" ToRole="ActionEduThematique" />
@@ -440,7 +440,7 @@
             <PropertyRef Name="Id" />
           </Key>
           <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Nom" Type="String" Nullable="false" />
+          <Property Name="Nom" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="Neutralise" Type="Boolean" Nullable="false" DefaultValue="False" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
           <NavigationProperty Name="ActionEduAxe" Relationship="CD67.FicheCollege.ActionEduAxeActionEduThematique" FromRole="ActionEduThematique" ToRole="ActionEduAxe" />
@@ -452,13 +452,14 @@
             <PropertyRef Name="Id" />
           </Key>
           <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Nom" Type="String" Nullable="false" />
-          <Property Name="Description" Type="String" Nullable="false" MaxLength="Max" />
+          <Property Name="Nom" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
+          <Property Name="Description" Type="String" Nullable="false" MaxLength="Max" Unicode="true" FixedLength="false" />
           <Property Name="Neutralise" Type="Boolean" Nullable="false" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
           <NavigationProperty Name="ActionEduThematique" Relationship="CD67.FicheCollege.ActionEduThematiqueActionEdu" FromRole="ActionEdu" ToRole="ActionEduThematique" />
           <Property Name="ActionEduThematiqueId" Type="Int32" Nullable="false" />
           <NavigationProperty Name="Annee" Relationship="CD67.FicheCollege.ActionEduAnnee" FromRole="ActionEdu" ToRole="Annee" />
+          <Property Name="AnneeId" Type="Int32" Nullable="false" />
         </EntityType>
         <Association Name="ActionEduAxeActionEduThematique">
           <End Type="CD67.FicheCollege.ActionEduAxe" Role="ActionEduAxe" Multiplicity="1" />
@@ -487,6 +488,14 @@
         <Association Name="ActionEduAnnee">
           <End Type="CD67.FicheCollege.ActionEdu" Role="ActionEdu" Multiplicity="*" />
           <End Type="CD67.FicheCollege.Annee" Role="Annee" Multiplicity="1" />
+          <ReferentialConstraint>
+            <Principal Role="Annee">
+              <PropertyRef Name="Id" />
+            </Principal>
+            <Dependent Role="ActionEdu">
+              <PropertyRef Name="AnneeId" />
+            </Dependent>
+          </ReferentialConstraint>
         </Association>
         </Schema>
     </edmx:ConceptualModels>
@@ -613,17 +622,10 @@
           <ScalarProperty Name="Neutralise" ColumnName="Neutralise" />
           <ScalarProperty Name="Ordre" ColumnName="Ordre" />
           <ScalarProperty Name="ActionEduThematiqueId" ColumnName="ActionEduThematiqueId" />
+          <ScalarProperty Name="AnneeId" ColumnName="AnneeId" />
         </MappingFragment>
       </EntityTypeMapping>
     </EntitySetMapping>
-    <AssociationSetMapping Name="ActionEduAnnee" TypeName="CD67.FicheCollege.ActionEduAnnee" StoreEntitySet="ActionsEdu">
-      <EndProperty Name="Annee">
-        <ScalarProperty Name="Id" ColumnName="Annee_Id" />
-      </EndProperty>
-      <EndProperty Name="ActionEdu">
-        <ScalarProperty Name="Id" ColumnName="Id" />
-      </EndProperty>
-    </AssociationSetMapping>
   </EntityContainerMapping>
 </Mapping></edmx:Mappings>
   </edmx:Runtime>

+ 31 - 28
CD67.FicheCollege.Entity/EntityModel.edmx.sql

@@ -2,7 +2,7 @@
 -- --------------------------------------------------
 -- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
 -- --------------------------------------------------
--- Date Created: 02/28/2018 15:56:26
+-- Date Created: 03/01/2018 11:40:44
 -- Generated from EDMX file: C:\dev\dotnet\FicheCollege\CD67.FicheCollege.Entity\EntityModel.edmx
 -- --------------------------------------------------
 
@@ -17,6 +17,18 @@ GO
 -- Dropping existing FOREIGN KEY constraints
 -- --------------------------------------------------
 
+IF OBJECT_ID(N'[dbo].[FK_ActionEduAnnee]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[ActionsEdu] DROP CONSTRAINT [FK_ActionEduAnnee];
+GO
+IF OBJECT_ID(N'[dbo].[FK_ActionEduAxeActionEduThematique]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[ActionEduThematiques] DROP CONSTRAINT [FK_ActionEduAxeActionEduThematique];
+GO
+IF OBJECT_ID(N'[dbo].[FK_ActionEduThematiqueActionEdu]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[ActionsEdu] DROP CONSTRAINT [FK_ActionEduThematiqueActionEdu];
+GO
+IF OBJECT_ID(N'[dbo].[FK_AnneeCollege]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Colleges] DROP CONSTRAINT [FK_AnneeCollege];
+GO
 IF OBJECT_ID(N'[dbo].[FK_Colleges_Territoires]', 'F') IS NOT NULL
     ALTER TABLE [dbo].[Colleges] DROP CONSTRAINT [FK_Colleges_Territoires];
 GO
@@ -26,25 +38,22 @@ GO
 IF OBJECT_ID(N'[dbo].[FK_FicheIdentite_College]', 'F') IS NOT NULL
     ALTER TABLE [dbo].[Identites] DROP CONSTRAINT [FK_FicheIdentite_College];
 GO
-IF OBJECT_ID(N'[dbo].[FK_AnneeCollege]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[Colleges] DROP CONSTRAINT [FK_AnneeCollege];
-GO
-IF OBJECT_ID(N'[dbo].[FK_ActionEduAxeActionEduThematique]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[ActionEduThematiques] DROP CONSTRAINT [FK_ActionEduAxeActionEduThematique];
-GO
-IF OBJECT_ID(N'[dbo].[FK_ActionEduThematiqueActionEdu]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[ActionsEdu] DROP CONSTRAINT [FK_ActionEduThematiqueActionEdu];
-GO
 
 -- --------------------------------------------------
 -- Dropping existing tables
 -- --------------------------------------------------
 
-IF OBJECT_ID(N'[dbo].[TypesCollege]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[TypesCollege];
+IF OBJECT_ID(N'[dbo].[ActionEduAxes]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[ActionEduAxes];
 GO
-IF OBJECT_ID(N'[dbo].[Territoires]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[Territoires];
+IF OBJECT_ID(N'[dbo].[ActionEduThematiques]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[ActionEduThematiques];
+GO
+IF OBJECT_ID(N'[dbo].[ActionsEdu]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[ActionsEdu];
+GO
+IF OBJECT_ID(N'[dbo].[Annees]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Annees];
 GO
 IF OBJECT_ID(N'[dbo].[Colleges]', 'U') IS NOT NULL
     DROP TABLE [dbo].[Colleges];
@@ -52,17 +61,11 @@ GO
 IF OBJECT_ID(N'[dbo].[Identites]', 'U') IS NOT NULL
     DROP TABLE [dbo].[Identites];
 GO
-IF OBJECT_ID(N'[dbo].[Annees]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[Annees];
-GO
-IF OBJECT_ID(N'[dbo].[ActionEduAxes]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[ActionEduAxes];
-GO
-IF OBJECT_ID(N'[dbo].[ActionEduThematiques]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[ActionEduThematiques];
+IF OBJECT_ID(N'[dbo].[Territoires]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Territoires];
 GO
-IF OBJECT_ID(N'[dbo].[ActionsEdu]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[ActionsEdu];
+IF OBJECT_ID(N'[dbo].[TypesCollege]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[TypesCollege];
 GO
 
 -- --------------------------------------------------
@@ -180,7 +183,7 @@ CREATE TABLE [dbo].[ActionsEdu] (
     [Neutralise] bit  NOT NULL,
     [Ordre] int  NOT NULL,
     [ActionEduThematiqueId] int  NOT NULL,
-    [Annee_Id] int  NOT NULL
+    [AnneeId] int  NOT NULL
 );
 GO
 
@@ -324,10 +327,10 @@ ON [dbo].[ActionsEdu]
     ([ActionEduThematiqueId]);
 GO
 
--- Creating foreign key on [Annee_Id] in table 'ActionsEdu'
+-- Creating foreign key on [AnneeId] in table 'ActionsEdu'
 ALTER TABLE [dbo].[ActionsEdu]
 ADD CONSTRAINT [FK_ActionEduAnnee]
-    FOREIGN KEY ([Annee_Id])
+    FOREIGN KEY ([AnneeId])
     REFERENCES [dbo].[Annees]
         ([Id])
     ON DELETE NO ACTION ON UPDATE NO ACTION;
@@ -336,7 +339,7 @@ GO
 -- Creating non-clustered index for FOREIGN KEY 'FK_ActionEduAnnee'
 CREATE INDEX [IX_FK_ActionEduAnnee]
 ON [dbo].[ActionsEdu]
-    ([Annee_Id]);
+    ([AnneeId]);
 GO
 
 -- --------------------------------------------------

+ 10 - 2
CD67.FicheCollege.Entity/Extend/ActionEdu.cs

@@ -20,10 +20,18 @@ namespace CD67.FicheCollege.Entity
     /// </summary>
     public class ActionEdu_Metadata
     {
-        [Required(ErrorMessage = "Obligatoire")]
+        [Required]
         public int Id { get; set; }
 
-        [Required(ErrorMessage = "Obligatoire")]
+        [Required]
+        [Display(Name = "Année")]
+        public int AnneeId { get; set; }
+
+        [Required]
+        [Display(Name = "Thématique")]
+        public int ActionEduThematiqueId { get; set; }
+
+        [Required]
         [Display(Name = "Action")]
         public string Nom { get; set; }
 

+ 0 - 1
CD67.FicheCollege.Entity/Model_initial_inserts.sql

@@ -1,6 +1,5 @@
 USE [FicheCollege]
 
-DELETE FROM [Actions-CLAS];
 DELETE FROM Identites;
 DELETE FROM Colleges;
 

+ 5 - 5
CD67.FicheCollege.Factory/ActionEduAxeFactory.cs

@@ -21,7 +21,7 @@ namespace CD67.FicheCollege.Factory
             //Cas de sortie immédiate
             if (item.Ordre == 1) return;
 
-            Entity.TypeCollege itemToSubstitute = dbContext.TypesCollege.Where(i => i.Ordre == ordre - 1).First();
+            Entity.ActionEduAxe itemToSubstitute = dbContext.ActionEduAxes.Where(i => i.Ordre == ordre - 1).First();
             itemToSubstitute.Ordre += 1;
             item.Ordre -= 1;
             dbContext.SaveChanges();
@@ -32,9 +32,9 @@ namespace CD67.FicheCollege.Factory
             int ordre = item.Ordre;
 
             //Cas de sortie immédiate
-            if (item.Ordre == dbContext.TypesCollege.Max(i => i.Ordre)) return;
+            if (item.Ordre == dbContext.ActionEduAxes.Max(i => i.Ordre)) return;
 
-            Entity.TypeCollege itemToSubstitute = dbContext.TypesCollege.Where(i => i.Ordre == ordre + 1).First();
+            Entity.ActionEduAxe itemToSubstitute = dbContext.ActionEduAxes.Where(i => i.Ordre == ordre + 1).First();
             itemToSubstitute.Ordre -= 1;
             item.Ordre += 1;
             dbContext.SaveChanges();
@@ -53,8 +53,8 @@ namespace CD67.FicheCollege.Factory
         public override void add(ref Entity.ActionEduAxe entity)
         {
             //Initialisation de l'ordre
-            if (dbContext.TypesCollege.Count() == 0) entity.Ordre = 1;
-            else entity.Ordre = dbContext.TypesCollege.Max(i => i.Ordre) + 1;
+            if (dbContext.ActionEduAxes.Count() == 0) entity.Ordre = 1;
+            else entity.Ordre = dbContext.ActionEduAxes.Max(i => i.Ordre) + 1;
 
             base.add(ref entity);
         }

+ 68 - 0
CD67.FicheCollege.Factory/ActionEduFactory.cs

@@ -0,0 +1,68 @@
+using CD67.FicheCollege.Entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data.Entity;
+
+namespace CD67.FicheCollege.Factory
+{
+    public partial class ActionEduFactory : Internal.BaseFactory<Entity.ActionEdu>
+    {
+        public override IQueryable<Entity.ActionEdu> getAll()
+        {
+            return base.getAll("Ordre");
+        }
+
+        public void Up(ref Entity.ActionEdu item)
+        {
+            int ordre = item.Ordre;
+
+            //Cas de sortie immédiate
+            if (item.Ordre == 1) return;
+
+            Entity.ActionEdu itemToSubstitute = dbContext.ActionsEdu.Where(i => i.Ordre == ordre - 1).First();
+            itemToSubstitute.Ordre += 1;
+            item.Ordre -= 1;
+            dbContext.SaveChanges();
+        }
+
+        public void Down(ref Entity.ActionEdu item)
+        {
+            int ordre = item.Ordre;
+
+            //Cas de sortie immédiate
+            if (item.Ordre == dbContext.ActionsEdu.Max(i => i.Ordre)) return;
+
+            Entity.ActionEdu itemToSubstitute = dbContext.ActionsEdu.Where(i => i.Ordre == ordre + 1).First();
+            itemToSubstitute.Ordre -= 1;
+            item.Ordre += 1;
+            dbContext.SaveChanges();
+        }
+
+        private void Sort()
+        {
+            int ordre = 1;
+            foreach (Entity.ActionEdu statut in dbContext.ActionsEdu.OrderBy(i => i.Ordre))
+            {
+                statut.Ordre = ordre++;
+            }
+            dbContext.SaveChanges();
+        }
+
+        public override void add(ref Entity.ActionEdu entity)
+        {
+            //Initialisation de l'ordre
+            if (dbContext.ActionsEdu.Count() == 0) entity.Ordre = 1;
+            else entity.Ordre = dbContext.ActionsEdu.Max(i => i.Ordre) + 1;
+
+            base.add(ref entity);
+        }
+
+        public override void delete(ref Entity.ActionEdu entity)
+        {
+            base.delete(ref entity);
+            Sort();
+        }
+    }
+}

+ 5 - 5
CD67.FicheCollege.Factory/ActionEduThematiqueFactory.cs

@@ -21,7 +21,7 @@ namespace CD67.FicheCollege.Factory
             //Cas de sortie immédiate
             if (item.Ordre == 1) return;
 
-            Entity.TypeCollege itemToSubstitute = dbContext.TypesCollege.Where(i => i.Ordre == ordre - 1).First();
+            Entity.ActionEduThematique itemToSubstitute = dbContext.ActionEduThematiques.Where(i => i.Ordre == ordre - 1).First();
             itemToSubstitute.Ordre += 1;
             item.Ordre -= 1;
             dbContext.SaveChanges();
@@ -32,9 +32,9 @@ namespace CD67.FicheCollege.Factory
             int ordre = item.Ordre;
 
             //Cas de sortie immédiate
-            if (item.Ordre == dbContext.TypesCollege.Max(i => i.Ordre)) return;
+            if (item.Ordre == dbContext.ActionEduThematiques.Max(i => i.Ordre)) return;
 
-            Entity.TypeCollege itemToSubstitute = dbContext.TypesCollege.Where(i => i.Ordre == ordre + 1).First();
+            Entity.ActionEduThematique itemToSubstitute = dbContext.ActionEduThematiques.Where(i => i.Ordre == ordre + 1).First();
             itemToSubstitute.Ordre -= 1;
             item.Ordre += 1;
             dbContext.SaveChanges();
@@ -53,8 +53,8 @@ namespace CD67.FicheCollege.Factory
         public override void add(ref Entity.ActionEduThematique entity)
         {
             //Initialisation de l'ordre
-            if (dbContext.TypesCollege.Count() == 0) entity.Ordre = 1;
-            else entity.Ordre = dbContext.TypesCollege.Max(i => i.Ordre) + 1;
+            if (dbContext.ActionEduThematiques.Count() == 0) entity.Ordre = 1;
+            else entity.Ordre = dbContext.ActionEduThematiques.Max(i => i.Ordre) + 1;
 
             base.add(ref entity);
         }

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

@@ -54,6 +54,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ActionEduFactory.cs" />
     <Compile Include="ActionEduThematiqueFactory.cs" />
     <Compile Include="AnneeFactory.cs" />
     <Compile Include="CollegeFactory.cs" />

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

@@ -157,6 +157,7 @@
   <ItemGroup>
     <Compile Include="App_Start\BundleConfig.cs" />
     <Compile Include="Controllers\ActionEduAxesController.cs" />
+    <Compile Include="Controllers\ActionsEduCollegeController.cs" />
     <Compile Include="Controllers\ActionsEduController.cs" />
     <Compile Include="Controllers\ActionEduThematiquesController.cs" />
     <Compile Include="Controllers\AdminController.cs" />
@@ -400,7 +401,7 @@
     <Content Include="Views\Annees\Details.cshtml" />
     <Content Include="Views\Annees\Index.cshtml" />
     <Content Include="Views\Colleges\Index.cshtml" />
-    <Content Include="Views\ActionsEdu\Index.cshtml" />
+    <Content Include="Views\ActionsEduCollege\Index.cshtml" />
     <Content Include="Views\ActionEduAxes\Create.cshtml" />
     <Content Include="Views\ActionEduAxes\Delete.cshtml" />
     <Content Include="Views\ActionEduAxes\Edit.cshtml" />
@@ -409,6 +410,10 @@
     <Content Include="Views\ActionEduThematiques\Delete.cshtml" />
     <Content Include="Views\ActionEduThematiques\Edit.cshtml" />
     <Content Include="Views\ActionEduThematiques\Index.cshtml" />
+    <Content Include="Views\ActionsEdu\Create.cshtml" />
+    <Content Include="Views\ActionsEdu\Delete.cshtml" />
+    <Content Include="Views\ActionsEdu\Edit.cshtml" />
+    <Content Include="Views\ActionsEdu\Index.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />

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

@@ -36,8 +36,8 @@ namespace CD67.FicheCollege.MVC.Controllers
         {
             if (ModelState.IsValid)
             {
-                ActionEduAxeFactory ActionEduAxeFactory = new ActionEduAxeFactory(db);
-                ActionEduAxeFactory.add(ref axe);
+                ActionEduAxeFactory fact = new ActionEduAxeFactory(db);
+                fact.add(ref axe);
                 return RedirectToAction("Index");
             }
 

+ 30 - 0
CD67.FicheCollege.MVC/Controllers/ActionsEduCollegeController.cs

@@ -0,0 +1,30 @@
+using CD67.FicheCollege.Entity;
+using CD67.FicheCollege.Factory;
+using CD67.FicheCollege.MVC.Models;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Web;
+using System.Web.Mvc;
+
+namespace CD67.FicheCollege.MVC.Controllers
+{
+    public class ActionsEduCollegeController : Controller
+    {
+        private Entities db = new Entities();
+
+        // GET: Actions
+        public ActionResult Index(int? annee_id)
+        {
+            if (annee_id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+
+            AnneeFactory fact = new AnneeFactory(db);
+            Annee annee = fact.getById(annee_id);
+            AnneeViewModel model = new AnneeViewModel(annee, ModeAcces.Lecture);
+            return View(model);
+        }
+    }
+}

+ 128 - 1
CD67.FicheCollege.MVC/Controllers/ActionsEduController.cs

@@ -20,12 +20,139 @@ namespace CD67.FicheCollege.MVC.Controllers
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
-
             AnneeFactory fact = new AnneeFactory(db);
             Annee annee = fact.getById(annee_id);
             AnneeViewModel model = new AnneeViewModel(annee, ModeAcces.Lecture);
             return View(model);
         }
 
+        // GET: ActionEduAxe/Create
+        public ActionResult Create(int? annee_id)
+        {
+            if (annee_id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionEdu actionEdu = new ActionEdu();
+            actionEdu.AnneeId = annee_id.Value;
+            AnneeFactory fact = new AnneeFactory(db);
+            actionEdu.Annee = fact.getById(annee_id);
+
+            ActionEduViewModel model = new ActionEduViewModel(actionEdu, db, ModeAcces.Creation);
+            return View(model);
+        }
+
+        // POST: ActionEduAxe/Create
+        // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 
+        // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Create(ActionEdu actionEdu)
+        {
+            if (ModelState.IsValid)
+            {
+                ActionEduFactory fact = new ActionEduFactory(db);
+                fact.add(ref actionEdu);
+                return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
+            }
+
+            ActionEduViewModel model = new ActionEduViewModel(actionEdu, db, ModeAcces.Creation);
+            return View(model);
+        }
+
+        // GET: ActionEduAxe/Edit/5
+        public ActionResult Edit(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionEduFactory fact = new ActionEduFactory(db);
+            ActionEdu action = fact.getById(id.Value);
+            if (action == null)
+            {
+                return HttpNotFound();
+            }
+            ActionEduViewModel model = new ActionEduViewModel(action, db, ModeAcces.Modification);
+            return View(model);
+        }
+
+        // POST: ActionEduAxe/Edit/5
+        // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 
+        // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Edit(ActionEdu actionEdu)
+        {
+            if (ModelState.IsValid)
+            {
+                ActionEduFactory fact = new ActionEduFactory(db);
+                fact.update(ref actionEdu);
+                return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
+            }
+            ActionEduViewModel model = new ActionEduViewModel(actionEdu, db, ModeAcces.Modification);
+            return View(model);
+        }
+
+        // GET: ActionEduAxe/Delete/5
+        public ActionResult Delete(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionEduFactory fact = new ActionEduFactory(db);
+            ActionEdu actionEdu = fact.getById(id.Value);
+            if (actionEdu == null)
+            {
+                return HttpNotFound();
+            }
+            ActionEduViewModel model = new ActionEduViewModel(actionEdu, db);
+            return View(model);
+        }
+
+        // POST: ActionEduAxe/Delete/5
+        [HttpPost, ActionName("Delete")]
+        [ValidateAntiForgeryToken]
+        public ActionResult DeleteConfirmed(int id)
+        {
+            ActionEduFactory fact = new ActionEduFactory(db);
+            ActionEdu actionEdu = fact.getById(id);
+            fact.delete(ref actionEdu);
+            return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
+        }
+
+        public ActionResult Up(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionEduFactory fact = new ActionEduFactory(db);
+            ActionEdu actionEdu = fact.getById(id.Value);
+            fact.Up(ref actionEdu);
+            return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
+        }
+
+        public ActionResult Down(int? id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionEduFactory fact = new ActionEduFactory(db);
+            ActionEdu actionEdu = fact.getById(id.Value);
+            fact.Down(ref actionEdu);
+            return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                db.Dispose();
+            }
+            base.Dispose(disposing);
+        }
     }
 }

+ 18 - 1
CD67.FicheCollege.MVC/Models/ActionEduViewModel.cs

@@ -8,11 +8,28 @@ namespace CD67.FicheCollege.MVC.Models
 {
     public class ActionEduViewModel : BaseViewModel<ActionEdu>
     {
-        public ActionEduViewModel(ActionEdu model, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
+        public SelectList Sel_Thematique;
+
+        public ActionEduViewModel(ActionEdu model, Entities dbContext, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
         {
+            if (acces == ModeAcces.Creation | acces == ModeAcces.Modification)
+            {
+                ActionEduThematiqueFactory fact = new ActionEduThematiqueFactory(dbContext);
+                Sel_Thematique = new SelectList(fact.getAll(), "Id", "Nom", Obj.ActionEduThematiqueId);
+            }
         }
 
         public override string Annee_Lib { get { return Obj.Annee.Libelle; } }
 
     }
+
+    public class ActionEduIndexViewModel : BaseViewModel<IEnumerable<ActionEdu>>
+    {
+        public ActionEduIndexViewModel(IEnumerable<ActionEdu> model, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
+        {
+        }
+
+        public override string Annee_Lib { get { return ""; } }
+
+    }
 }

+ 1 - 1
CD67.FicheCollege.MVC/Views/ActionEduAxes/Index.cshtml

@@ -28,7 +28,7 @@
         <th></th>
     </tr>
 
-    @foreach (var item in Model.Obj)
+    @foreach (var item in Model.Obj.OrderBy(i => i.Ordre))
     {
         <tr>
             <td>

+ 1 - 1
CD67.FicheCollege.MVC/Views/ActionEduThematiques/Index.cshtml

@@ -32,7 +32,7 @@
         <th></th>
     </tr>
 
-    @foreach (var item in Model.Obj)
+    @foreach (var item in Model.Obj.OrderBy(i => i.Ordre))
     {
         <tr>
             <td>

+ 68 - 0
CD67.FicheCollege.MVC/Views/ActionsEdu/Create.cshtml

@@ -0,0 +1,68 @@
+@using CD67.FicheCollege.MVC.Models
+@model ActionEduViewModel
+
+@{
+    ViewBag.Title = "Création";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionEdu actionEdu = Model.Obj;
+}
+
+@using (Html.BeginForm()) 
+{
+    @Html.AntiForgeryToken()
+    
+    <div class="form-horizontal">
+        <h4>Actions</h4>
+        <hr />
+        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
+        @Html.HiddenFor(model => actionEdu.Id)
+        @Html.HiddenFor(model => actionEdu.Ordre)
+        @Html.HiddenFor(model => actionEdu.AnneeId)
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Nom, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Nom, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Nom, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Description, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Description, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Description, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Neutralise, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Neutralise, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Neutralise, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.ActionEduThematiqueId, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.DropDownListFor(model => actionEdu.ActionEduThematiqueId, Model.Sel_Thematique, htmlAttributes: new { @class = "form-control" })
+                @Html.ValidationMessageFor(model => actionEdu.ActionEduThematiqueId, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            <div class="col-md-offset-2 col-md-10">
+                <input type="submit" value="Créer" class="btn btn-default" />
+            </div>
+        </div>
+    </div>
+}
+
+<div>
+    @Html.ActionLink("Retour à la liste", "Index")
+</div>
+
+@section Scripts {
+
+}

+ 35 - 0
CD67.FicheCollege.MVC/Views/ActionsEdu/Delete.cshtml

@@ -0,0 +1,35 @@
+@using CD67.FicheCollege.MVC.Models
+@model ActionEduViewModel
+
+@{
+    ViewBag.Title = "Suppression";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionEdu action = Model.Obj;
+}
+
+<h2>Suppression</h2>
+
+<h3>Voulez-vous vraiment supprimer cet élément?</h3>
+<div>
+    <h4>Action</h4>
+    <hr />
+    <dl class="dl-horizontal">
+        <dt>
+            @Html.DisplayNameFor(model => action.Nom)
+        </dt>
+
+        <dd>
+            @Html.DisplayFor(model => action.Nom)
+        </dd>
+
+    </dl>
+
+    @using (Html.BeginForm()) {
+        @Html.AntiForgeryToken()
+
+        <div class="form-actions no-color">
+            <input type="submit" value="Supprimer" class="btn btn-default" /> |
+            @Html.ActionLink("Retour à la liste", "Index")
+        </div>
+    }
+</div>

+ 71 - 0
CD67.FicheCollege.MVC/Views/ActionsEdu/Edit.cshtml

@@ -0,0 +1,71 @@
+@using CD67.FicheCollege.MVC.Models
+@model ActionEduViewModel
+
+@{
+    ViewBag.Title = "Modification";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionEdu actionEdu = Model.Obj;
+}
+
+<h2>Modification</h2>
+
+
+@using (Html.BeginForm())
+{
+    @Html.AntiForgeryToken()
+    
+    <div class="form-horizontal">
+        <h4>Actions</h4>
+        <hr />
+        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
+        @Html.HiddenFor(model => actionEdu.Id)
+        @Html.HiddenFor(model => actionEdu.Ordre)
+        @Html.HiddenFor(model => actionEdu.AnneeId)
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Nom, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Nom, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Nom, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Description, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Description, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Description, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.Neutralise, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.EditorFor(model => actionEdu.Neutralise, new { htmlAttributes = new { @class = "form-control" } })
+                @Html.ValidationMessageFor(model => actionEdu.Neutralise, "", new { @class = "text-danger" })
+            </div>
+        </div>
+        
+        <div class="form-group">
+            @Html.LabelFor(model => actionEdu.ActionEduThematiqueId, htmlAttributes: new { @class = "control-label col-md-2" })
+            <div class="col-md-10">
+                @Html.DropDownListFor(model => actionEdu.ActionEduThematiqueId, Model.Sel_Thematique, htmlAttributes: new { @class = "form-control" })
+                @Html.ValidationMessageFor(model => actionEdu.ActionEduThematiqueId, "", new { @class = "text-danger" })
+            </div>
+        </div>
+
+        <div class="form-group">
+            <div class="col-md-offset-2 col-md-10">
+                <input type="submit" value="Enregistrer" class="btn btn-default" />
+            </div>
+        </div>
+    </div>
+}
+
+<div>
+    @Html.ActionLink("Retour à la liste", "Index")
+</div>
+
+@section Scripts {
+
+}

+ 81 - 12
CD67.FicheCollege.MVC/Views/ActionsEdu/Index.cshtml

@@ -1,22 +1,91 @@
 @using CD67.FicheCollege.MVC.Models
 @model AnneeViewModel
 
-<title>Actions @Model.Annee_Lib</title>
-
 @{
-    ViewBag.Title = "Actions " + @Model.Annee_Lib;
+    ViewBag.Title = "Liste";
     Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionEdu action_model = new ActionEdu();
+    int maxOrdre = Model.Obj.ActionsEdu.Count() == 0 ? 0 : Model.Obj.ActionsEdu.Max(i => i.Ordre);
+    int row = 1;
 }
 
-<h2>Index</h2>
+<h2>Liste</h2>
+
+<p>
+    <a href="@Url.Action("Create", new { annee_id = Model.Obj.Id })">
+        <span class="glyphicon glyphicon-plus-sign fa-2x color1" style="vertical-align: middle" aria-hidden="true"></span>
+        Créer un nouvel élément
+    </a>
+</p>
 
-<h3>Affectation</h3>
-<br/>
+<table class="table">
+    <tr>
+        <th>
+            @Html.DisplayNameFor(model => action_model.Nom)
+        </th>
+        <th>
+            @Html.DisplayNameFor(model => action_model.Description)
+        </th>
+        <th>
+            @Html.DisplayNameFor(model => action_model.Neutralise)
+        </th>
+        <th>
+            @Html.DisplayNameFor(model => action_model.ActionEduThematique.ActionEduAxeId)
+        </th>
+        <th>
+            @Html.DisplayNameFor(model => action_model.ActionEduThematiqueId)
+        </th>
+        <th></th>
+    </tr>
 
-<h3>Administration</h3>
+    @foreach (ActionEdu item in Model.Obj.ActionsEdu.OrderBy(i=>i.Ordre))
+    {
+        <tr>
+            <td>
+                @Html.DisplayFor(modelItem => item.Nom)
+            </td>
+            <td>
+                @Html.DisplayFor(modelItem => item.Description)
+            </td>        
+            <td>
+                @Html.DisplayFor(modelItem => item.Neutralise)
+            </td>
+            <th>
+                @Html.DisplayFor(model => item.ActionEduThematique.ActionEduAxeId)
+            </th>
+            <th>
+                @Html.DisplayFor(model => item.ActionEduThematiqueId)
+            </th>
+            <td>
+                @if (row != 1)
+                    {
+                    <a href="@Url.Action("Up", new { id = item.Id })">
+                        <span class="glyphicon glyphicon-circle-arrow-up fa-2x color1" title="Remonter" style="vertical-align: middle" aria-hidden="true"></span>
+                    </a>
+                }
+                else
+                {
+                    <span class="glyphicon glyphicon-circle-arrow-up fa-2x color2" title="Remonter" style="vertical-align: middle" aria-hidden="true"></span>
+                }
+                @if (item.Ordre != maxOrdre)
+                    {
+                    <a href="@Url.Action("Down", new { id = item.Id })">
+                        <span class="glyphicon glyphicon-circle-arrow-down fa-2x color1" title="Descendre" style="vertical-align: middle" aria-hidden="true"></span>
+                    </a>
+                }
+                else
+                {
+                    <span class="glyphicon glyphicon-circle-arrow-down fa-2x color2" title="Descendre" style="vertical-align: middle" aria-hidden="true"></span>
+                }
+                <a href="@Url.Action("Edit", new { id = item.Id })">
+                    <span class="glyphicon glyphicon-edit fa-2x color1" title="Modifier" style="vertical-align: middle" aria-hidden="true"></span>
+                </a>
+                <a href="@Url.Action("Delete", new { id = item.Id })">
+                    <span class="glyphicon glyphicon-remove-sign fa-2x color1" title="Supprimer" style="vertical-align: middle" aria-hidden="true"></span>
+                </a>
+            </td>
+        </tr>
+        row += 1;
+    }
 
-<ul>
-    <li>@Html.ActionLink("Les axes", "Index", "ActionAxes")</li>
-    <li>@Html.ActionLink("Les thématiques", "Index", "ActionThematiques")</li>
-    <li>@Html.ActionLink("Les actions " + @Model.Annee_Lib, "Index", "Admin", new { annee_id = Model.Obj.Id }, null)</li>
-</ul>
+</table>

+ 22 - 0
CD67.FicheCollege.MVC/Views/ActionsEduCollege/Index.cshtml

@@ -0,0 +1,22 @@
+@using CD67.FicheCollege.MVC.Models
+@model AnneeViewModel
+
+<title>Actions @Model.Annee_Lib</title>
+
+@{
+    ViewBag.Title = "Actions " + @Model.Annee_Lib;
+    Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+<h2>Index</h2>
+
+<h3>Affectation</h3>
+<br/>
+
+<h3>Administration</h3>
+
+<ul>
+    <li>@Html.ActionLink("Les axes", "Index", "ActionEduAxes")</li>
+    <li>@Html.ActionLink("Les thématiques", "Index", "ActionEduThematiques")</li>
+    <li>@Html.ActionLink("Les actions " + @Model.Annee_Lib, "Index", "ActionsEdu", new { annee_id = Model.Obj.Id }, null)</li>
+</ul>

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

@@ -12,6 +12,6 @@
 
 <ul>
     <li>@Html.ActionLink("Les collèges", "Index", "Colleges", new { annee_id = Model.Obj.Id }, null)</li>
-    <li>@Html.ActionLink("Les actions", "Index", "Actions", 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>