Sfoglia il codice sorgente

CHG Modification des territoires pour utiliser le code TAD comme ID

julien.legrand 8 anni fa
parent
commit
a67ee15919

+ 2 - 1
CD67.FicheCollege.BDD/Territoires.sql

@@ -1,11 +1,12 @@
 CREATE TABLE [dbo].[Territoires]
 (
-	[Id] INT NOT NULL PRIMARY KEY IDENTITY, 
+	[Id] NVARCHAR(10) NOT NULL PRIMARY KEY, 
     [Libelle] NVARCHAR(255) NOT NULL, 
     [Referent_SID] NVARCHAR(64) NULL, 
     [Referent_Nom] NVARCHAR(255) NULL, 
     [Referent_Prenom] NVARCHAR(255) NULL, 
     [Referent_Structure] NVARCHAR(255) NULL, 
     [Referent_Login] NVARCHAR(255) NULL, 
+	[Referent_Email] NVARCHAR(255) NULL, 
     [Ordre] INT NOT NULL
 )

+ 1 - 1
CD67.FicheCollege.Entity/EntityModel.Context.cs

@@ -25,7 +25,7 @@ namespace CD67.FicheCollege.Entity
             throw new UnintentionalCodeFirstException();
         }
     
-        public virtual DbSet<Territoire> Territoires { get; set; }
         public virtual DbSet<TypeCollege> TypesCollege { get; set; }
+        public virtual DbSet<Territoire> Territoires { get; set; }
     }
 }

+ 1 - 1
CD67.FicheCollege.Entity/EntityModel.Designer.cs

@@ -1,4 +1,4 @@
-// La génération de code T4 est activée pour le modèle 'C:\Users\julien.legrand\Documents\Developpements\FicheCollege\CD67.FicheCollege.Entity\EntityModel.edmx'. 
+// La génération de code T4 est activée pour le modèle 'C:\Users\julien.legrand\Documents\Developpements\FicheCollege_new\CD67.FicheCollege.Entity\EntityModel.edmx'. 
 // Pour activer la génération de code héritée, définissez la valeur de la propriété
 // du concepteur 'Stratégie de génération de code' sur 'ObjectContext hérité'. Cette propriété est disponible dans la fenêtre Propriétés lorsque le modèle
 //  est ouvert dans le concepteur.

+ 23 - 20
CD67.FicheCollege.Entity/EntityModel.edmx

@@ -9,13 +9,14 @@
           <Key>
             <PropertyRef Name="Id" />
           </Key>
-          <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Id" Type="nvarchar" MaxLength="10" Nullable="false" />
           <Property Name="Libelle" Type="nvarchar" MaxLength="255" Nullable="false" />
           <Property Name="Referent_SID" Type="nvarchar" MaxLength="64" />
           <Property Name="Referent_Nom" Type="nvarchar" MaxLength="255" />
           <Property Name="Referent_Prenom" Type="nvarchar" MaxLength="255" />
           <Property Name="Referent_Structure" Type="nvarchar" MaxLength="255" />
           <Property Name="Referent_Login" Type="nvarchar" MaxLength="255" />
+          <Property Name="Referent_Email" Type="nvarchar" MaxLength="255" />
           <Property Name="Ordre" Type="int" Nullable="false" />
         </EntityType>
         <EntityType Name="TypesCollege">
@@ -35,28 +36,29 @@
     <edmx:ConceptualModels>
       <Schema Namespace="CD67.FicheCollege" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
         <EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
-          <EntitySet Name="Territoires" EntityType="CD67.FicheCollege.Territoire" />
           <EntitySet Name="TypesCollege" EntityType="CD67.FicheCollege.TypeCollege" />
+          <EntitySet Name="Territoires" EntityType="CD67.FicheCollege.Territoire" />
         </EntityContainer>
-        <EntityType Name="Territoire">
+        <EntityType Name="TypeCollege">
           <Key>
             <PropertyRef Name="Id" />
           </Key>
-          <Property Name="Id" Type="Int32" Nullable="false" />
+          <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
           <Property Name="Libelle" Type="String" Nullable="false" MaxLength="255" FixedLength="false" Unicode="true" />
-          <Property Name="Referent_SID" Type="String" MaxLength="64" FixedLength="false" Unicode="true" />
-          <Property Name="Referent_Nom" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
-          <Property Name="Referent_Prenom" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
-          <Property Name="Referent_Structure" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
-          <Property Name="Referent_Login" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
         </EntityType>
-        <EntityType Name="TypeCollege">
+        <EntityType Name="Territoire">
           <Key>
             <PropertyRef Name="Id" />
           </Key>
-          <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Id" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="true" />
           <Property Name="Libelle" Type="String" Nullable="false" MaxLength="255" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_SID" Type="String" MaxLength="64" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_Nom" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_Prenom" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_Structure" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_Login" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
+          <Property Name="Referent_Email" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
           <Property Name="Ordre" Type="Int32" Nullable="false" />
         </EntityType>
       </Schema>
@@ -65,10 +67,20 @@
     <edmx:Mappings>
     <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
   <EntityContainerMapping StorageEntityContainer="ModeleMVCStoreContainer" CdmEntityContainer="Entities">
+          <EntitySetMapping Name="TypesCollege">
+            <EntityTypeMapping TypeName="CD67.FicheCollege.TypeCollege">
+              <MappingFragment StoreEntitySet="TypesCollege">
+                <ScalarProperty Name="Ordre" ColumnName="Ordre" />
+                <ScalarProperty Name="Libelle" ColumnName="Libelle" />
+                <ScalarProperty Name="Id" ColumnName="Id" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
           <EntitySetMapping Name="Territoires">
             <EntityTypeMapping TypeName="CD67.FicheCollege.Territoire">
               <MappingFragment StoreEntitySet="Territoires">
                 <ScalarProperty Name="Ordre" ColumnName="Ordre" />
+                <ScalarProperty Name="Referent_Email" ColumnName="Referent_Email" />
                 <ScalarProperty Name="Referent_Login" ColumnName="Referent_Login" />
                 <ScalarProperty Name="Referent_Structure" ColumnName="Referent_Structure" />
                 <ScalarProperty Name="Referent_Prenom" ColumnName="Referent_Prenom" />
@@ -79,15 +91,6 @@
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
-          <EntitySetMapping Name="TypesCollege">
-            <EntityTypeMapping TypeName="CD67.FicheCollege.TypeCollege">
-              <MappingFragment StoreEntitySet="TypesCollege">
-                <ScalarProperty Name="Ordre" ColumnName="Ordre" />
-                <ScalarProperty Name="Libelle" ColumnName="Libelle" />
-                <ScalarProperty Name="Id" ColumnName="Id" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
         </EntityContainerMapping>
 </Mapping></edmx:Mappings>
   </edmx:Runtime>

+ 1 - 1
CD67.FicheCollege.Entity/EntityModel.edmx.diagram

@@ -5,8 +5,8 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="86b727c7572a49c5b7e8139c8d489465" Name="Diagram1">
-        <EntityTypeShape EntityType="CD67.FicheCollege.Territoire" Width="1.5" PointX="0.75" PointY="0.75" />
         <EntityTypeShape EntityType="CD67.FicheCollege.TypeCollege" Width="1.5" PointX="2.75" PointY="0.75" />
+        <EntityTypeShape EntityType="CD67.FicheCollege.Territoire" Width="1.5" PointX="0.75" PointY="0.75" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 3 - 1
CD67.FicheCollege.Entity/Extend/Territoire.cs

@@ -22,7 +22,7 @@ namespace CD67.FicheCollege.Entity
     public class Territoire_Metadata
     {
         [Required(ErrorMessage = "Obligatoire")]
-        public int Id { get; set; }
+        public string Id { get; set; }
         [Required(ErrorMessage = "Obligatoire")]
         [Display(Name = "Territoire")]
         public string Libelle { get; set; }
@@ -36,6 +36,8 @@ namespace CD67.FicheCollege.Entity
         public string Referent_Structure { get; set; }
         [Display(Name = "Login du référent")]
         public string Referent_Login { get; set; }
+        [Display(Name = "Email du référent")]
+        public string Referent_Email { get; set; }
         public int Ordre { get; set; }
 
         [Display(Name = "Référent")]

+ 2 - 1
CD67.FicheCollege.Entity/Territoire.cs

@@ -14,13 +14,14 @@ namespace CD67.FicheCollege.Entity
     
     public partial class Territoire
     {
-        public int Id { get; set; }
+        public string Id { get; set; }
         public string Libelle { get; set; }
         public string Referent_SID { get; set; }
         public string Referent_Nom { get; set; }
         public string Referent_Prenom { get; set; }
         public string Referent_Structure { get; set; }
         public string Referent_Login { get; set; }
+        public string Referent_Email { get; set; }
         public int Ordre { get; set; }
     }
 }

+ 9 - 25
CD67.FicheCollege.MVC/Controllers/TerritoireController.cs

@@ -22,22 +22,6 @@ namespace CD67.FicheCollege.MVC.Controllers
             return View(territoireFactory.getAll());
         }
 
-        // GET: Territoire/Details/5
-        public ActionResult Details(int? id)
-        {
-            if (id == null)
-            {
-                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
-            }
-            TerritoireFactory territoireFactory = new TerritoireFactory(db);
-            Entity.Territoire territoire = territoireFactory.getById(id.Value);
-            if (territoire == null)
-            {
-                return HttpNotFound();
-            }
-            return View(territoire);
-        }
-
         // GET: Territoire/Create
         public ActionResult Create()
         {
@@ -63,14 +47,14 @@ namespace CD67.FicheCollege.MVC.Controllers
         }
 
         // GET: Territoire/Edit/5
-        public ActionResult Edit(int? id)
+        public ActionResult Edit(string id)
         {
             if (id == null)
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
             TerritoireFactory territoireFactory = new TerritoireFactory(db);
-            Entity.Territoire territoire = territoireFactory.getById(id.Value);
+            Entity.Territoire territoire = territoireFactory.getById(id);
             if (territoire == null)
             {
                 return HttpNotFound();
@@ -95,14 +79,14 @@ namespace CD67.FicheCollege.MVC.Controllers
         }
 
         // GET: Territoire/Delete/5
-        public ActionResult Delete(int? id)
+        public ActionResult Delete(string id)
         {
             if (id == null)
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
             TerritoireFactory territoireFactory = new TerritoireFactory(db);
-            Entity.Territoire territoire = territoireFactory.getById(id.Value);
+            Entity.Territoire territoire = territoireFactory.getById(id);
             if (territoire == null)
             {
                 return HttpNotFound();
@@ -113,7 +97,7 @@ namespace CD67.FicheCollege.MVC.Controllers
         // 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);
@@ -121,26 +105,26 @@ namespace CD67.FicheCollege.MVC.Controllers
             return RedirectToAction("Index");
         }
 
-        public ActionResult Up(int? id)
+        public ActionResult Up(string id)
         {
             if (id == null)
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
             TerritoireFactory territoireFactory = new TerritoireFactory(db);
-            Entity.Territoire territoire = territoireFactory.getById(id.Value);
+            Entity.Territoire territoire = territoireFactory.getById(id);
             territoireFactory.Up(ref territoire);
             return RedirectToAction("Index");
         }
 
-        public ActionResult Down(int? id)
+        public ActionResult Down(string id)
         {
             if (id == null)
             {
                 return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
             }
             TerritoireFactory territoireFactory = new TerritoireFactory(db);
-            Entity.Territoire territoire = territoireFactory.getById(id.Value);
+            Entity.Territoire territoire = territoireFactory.getById(id);
             territoireFactory.Down(ref territoire);
             return RedirectToAction("Index");
         }

+ 13 - 6
CD67.FicheCollege.MVC/Views/Territoire/Create.cshtml

@@ -16,9 +16,16 @@
         <h4>Territoire</h4>
         <hr />
         @Html.ValidationSummary(true, "", new { @class = "text-danger" })
-        @Html.HiddenFor(model => model.Id)
         @Html.HiddenFor(model => model.Ordre)
 
+        <div class="form-group">
+            @Html.LabelFor(model => model.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" })
+            </div>
+        </div>
+
         <div class="form-group">
             @Html.LabelFor(model => model.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
@@ -35,6 +42,7 @@
                 @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" })
                 <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> }">
@@ -43,10 +51,8 @@
                             <i class="fa fa-user color1" aria-hidden="true"></i>
                             Agent
                         </h4>
-                        <div class="btn-group pull-right">
-                            <a class="btn btn-danger btn-sm" href="#">
-                                <span class="glyphicon glyphicon-trash removeItem" aria-hidden="true" data-type="referent"></span>
-                            </a>
+                        <div class="pull-right">
+                            <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="referent"></span>
                         </div>
                     </div>
                     <div class="panel-body" style="text-align: center;">
@@ -75,10 +81,11 @@
             switch ($(this).data("type")) {
                 case 'referent':
                     $('#Referent_SID').val(null);
-                    $('#Referent_Prenom').val(null);
                     $('#Referent_Nom').val(null);
+                    $('#Referent_Prenom').val(null);
                     $('#Referent_Structure').val(null);
                     $('#Referent_Login').val(null);
+                    $('#Referent_Email').val(null);
                     $('#Referent_Panel').hide();
                     break;
                 default:

+ 15 - 0
CD67.FicheCollege.MVC/Views/Territoire/Delete.cshtml

@@ -12,6 +12,14 @@
     <h4>Territoire</h4>
     <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)
         </dt>
@@ -20,6 +28,13 @@
             @Html.DisplayFor(model => model.Libelle)
         </dd>
 
+        <dt>
+            @Html.DisplayNameFor(model => model.Referent)
+        </dt>
+
+        <dd>
+            @Html.DisplayFor(model => model.Referent)
+        </dd>
     </dl>
 
     @using (Html.BeginForm()) {

+ 13 - 5
CD67.FicheCollege.MVC/Views/Territoire/Edit.cshtml

@@ -19,6 +19,14 @@
         @Html.HiddenFor(model => model.Id)
         @Html.HiddenFor(model => model.Ordre)
 
+        <div class="form-group">
+            @Html.LabelFor(model => model.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" })
+            </div>
+        </div>
+
         <div class="form-group">
             @Html.LabelFor(model => model.Libelle, htmlAttributes: new { @class = "control-label col-md-2" })
             <div class="col-md-10">
@@ -35,6 +43,7 @@
                 @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" })
                 <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> }">
@@ -43,10 +52,8 @@
                             <i class="fa fa-user color1" aria-hidden="true"></i>
                             Agent
                         </h4>
-                        <div class="btn-group pull-right">
-                            <a class="btn btn-danger btn-sm" href="#">
-                                <span class="glyphicon glyphicon-trash removeItem" aria-hidden="true" data-type="referent"></span>
-                            </a>
+                        <div class="pull-right">
+                            <span class="glyphicon glyphicon-trash removeItem btn btn-danger btn-sm" aria-hidden="true" data-type="referent"></span>
                         </div>
                     </div>
                     <div class="panel-body" style="text-align: center;">
@@ -75,10 +82,11 @@
             switch ($(this).data("type")) {
                 case 'referent':
                     $('#Referent_SID').val(null);
-                    $('#Referent_Prenom').val(null);
                     $('#Referent_Nom').val(null);
+                    $('#Referent_Prenom').val(null);
                     $('#Referent_Structure').val(null);
                     $('#Referent_Login').val(null);
+                    $('#Referent_Email').val(null);
                     $('#Referent_Panel').hide();
                     break;
                 default:

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

@@ -18,24 +18,18 @@
 
 <table class="table">
     <tr>
-        <th>
-            @Html.DisplayNameFor(model => model.Libelle)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.Referent)
-        </th>
+        <th>@Html.DisplayNameFor(model => model.Id)</th>
+        <th>@Html.DisplayNameFor(model => model.Libelle)</th>
+        <th>@Html.DisplayNameFor(model => model.Referent)</th>
         <th></th>
     </tr>
 
 @foreach (var item in Model)
 {
     <tr>
-        <td>
-            @Html.DisplayFor(modelItem => item.Libelle)
-        </td>
-        <td>
-            @Html.DisplayFor(modelItem => item.Referent)
-        </td>
+        <td>@Html.DisplayFor(modelItem => item.Id)</td>
+        <td>@Html.DisplayFor(modelItem => item.Libelle)</td>
+        <td>@Html.DisplayFor(modelItem => item.Referent)</td>
         <td>
             @if (row != 1)
                 {