瀏覽代碼

FIX Correction creation de college

olivier.massot 7 年之前
父節點
當前提交
23715813d8
共有 2 個文件被更改,包括 13 次插入2 次删除
  1. 3 0
      CD67.FicheCollege.MVC/Models/CollegeViewModel.cs
  2. 10 2
      CD67.FicheCollege.MVC/Views/Colleges/Edit.cshtml

+ 3 - 0
CD67.FicheCollege.MVC/Models/CollegeViewModel.cs

@@ -10,6 +10,7 @@ namespace CD67.FicheCollege.MVC.Models
     {
     {
         public SelectList Sel_TypesCollege;
         public SelectList Sel_TypesCollege;
         public SelectList Sel_CodesPostaux;
         public SelectList Sel_CodesPostaux;
+        public SelectList Sel_Territoires;
 
 
         public CollegeViewModel(College model, Entities dbContext, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
         public CollegeViewModel(College model, Entities dbContext, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
         {
         {
@@ -17,6 +18,8 @@ namespace CD67.FicheCollege.MVC.Models
             {
             {
                 TypeCollegeFactory fact = new TypeCollegeFactory(dbContext);
                 TypeCollegeFactory fact = new TypeCollegeFactory(dbContext);
                 Sel_TypesCollege = new SelectList(fact.getAll(), "Id", "Libelle", Obj.TypeCollege_Id);
                 Sel_TypesCollege = new SelectList(fact.getAll(), "Id", "Libelle", Obj.TypeCollege_Id);
+                TerritoireFactory fact_t = new TerritoireFactory(dbContext);
+                Sel_Territoires = new SelectList(fact_t.getAll(), "Id", "Libelle", Obj.Territoire_Id);
                 Sel_CodesPostaux = new SelectList(Referentiel.GetCodesPostaux(Obj.Commune_Insee), Obj.Code_Postal);
                 Sel_CodesPostaux = new SelectList(Referentiel.GetCodesPostaux(Obj.Commune_Insee), Obj.Code_Postal);
             }
             }
         }
         }

+ 10 - 2
CD67.FicheCollege.MVC/Views/Colleges/Edit.cshtml

@@ -70,6 +70,14 @@ else
                 </div>
                 </div>
             </div>
             </div>
 
 
+            <div class="form-group">
+                @Html.LabelFor(model => college.Territoire_Id, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.DropDownListFor(model => college.Territoire_Id, Model.Sel_Territoires, htmlAttributes: new { @class = "form-control" })
+                    @Html.ValidationMessageFor(model => college.Territoire_Id, "", new { @class = "text-danger" })
+                </div>
+            </div>
+
             @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
             @Html.HiddenFor(model => college.Commune_Insee, new { data_picker = "commune.insee" })
             @Html.HiddenFor(model => college.Commune, new { data_picker = "commune.nom" })
             @Html.HiddenFor(model => college.Commune, new { data_picker = "commune.nom" })
             @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
             @Html.HiddenFor(model => college.Canton, new { data_picker = "commune.canton" })
@@ -190,12 +198,12 @@ else
             var code_postaux = $('#code_postaux').val();
             var code_postaux = $('#code_postaux').val();
             if (code_postaux != '') {
             if (code_postaux != '') {
                 //On vide la liste actuelle
                 //On vide la liste actuelle
-                $('#contenu_Code_Postal').empty();
+                $('#college_Code_Postal').empty();
 
 
                 var liste = code_postaux.split(',');
                 var liste = code_postaux.split(',');
                 liste.forEach(function (element) {
                 liste.forEach(function (element) {
                     //On ajoute les choix
                     //On ajoute les choix
-                    $('#contenu_Code_Postal').append($('<option>', {
+                    $('#college_Code_Postal').append($('<option>', {
                         value: element,
                         value: element,
                         text: element
                         text: element
                     }));
                     }));