Browse Source

NEW Lecture/Edition des actions CLAS

julien.legrand 8 years ago
parent
commit
538337e92a

+ 2 - 0
CD67.FicheCollege.Entity/Extend/ActionCLAS.cs

@@ -20,6 +20,8 @@ namespace CD67.FicheCollege.Entity
     /// </summary>
     public class ActionCLAS_Metadata
     {
+        [UIHint("YesNoBool")]
+        public Nullable<bool> Action { get; set; }
         [DataType(DataType.MultilineText)]
         public string Commentaire { get; set; }
     }

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

@@ -156,6 +156,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="App_Start\BundleConfig.cs" />
+    <Compile Include="Controllers\ActionsCLASController.cs" />
     <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\CollegesController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
@@ -387,6 +388,8 @@
     <Content Include="Views\Colleges\Index.cshtml" />
     <Content Include="Views\Identites\Details.cshtml" />
     <Content Include="Views\Identites\Edit.cshtml" />
+    <Content Include="Views\ActionsCLAS\Details.cshtml" />
+    <Content Include="Views\ActionsCLAS\Edit.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />

+ 87 - 0
CD67.FicheCollege.MVC/Controllers/ActionsCLASController.cs

@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Entity;
+using System.Linq;
+using System.Net;
+using System.Web;
+using System.Web.Mvc;
+using CD67.FicheCollege.Entity;
+using CD67.FicheCollege.Factory;
+
+namespace CD67.FicheCollege.MVC.Controllers
+{
+    public class ActionsCLASController : Controller
+    {
+        private Entities db = new Entities();
+
+        // GET: ActionCLAS/Details/5
+        public ActionResult Details(string id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
+            Entity.ActionCLAS actionClas = actionClasFactory.getById(id);
+            if (actionClas == null)
+            {
+                return HttpNotFound();
+            }
+            return View(GetViewModel(actionClas, Models.ModeAcces.Lecture));
+        }
+
+        // GET: ActionCLAS/Edit/5
+        public ActionResult Edit(string id)
+        {
+            if (id == null)
+            {
+                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
+            }
+            ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
+            Entity.ActionCLAS actionClas = actionClasFactory.getById(id);
+            if (actionClas == null)
+            {
+                return HttpNotFound();
+            }
+            return View(GetViewModel(actionClas, Models.ModeAcces.Modification));
+        }
+
+        // POST: ActionCLAS/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(ActionCLAS Contenu)
+        {
+            if (ModelState.IsValid)
+            {
+                ActionCLASFactory actionClasFactory = new ActionCLASFactory(db);
+                actionClasFactory.update(ref Contenu);
+                return RedirectToAction("Index");
+            }
+            return View(GetViewModel(Contenu, Models.ModeAcces.Modification));
+        }
+
+        private Models.CollegeViewModel GetViewModel(Entity.ActionCLAS entity, Models.ModeAcces Acces)
+        {
+            return new Models.CollegeViewModel()
+            {
+                College_Id = entity.College.Id,
+                College_Libelle = entity.College.Libelle,
+                Contenu = entity,
+                Acces = Acces,
+                Listes = null
+            };
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                db.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+    }
+}

+ 4 - 0
CD67.FicheCollege.MVC/Mvc.sitemap

@@ -14,6 +14,10 @@
         <mvcSiteMapNode title="Identité" controller="Identites" action="Details" preservedRouteParameters="id" >
           <mvcSiteMapNode title="Edition de l'identité" controller="Identites" action="Edit" preservedRouteParameters="id" />
         </mvcSiteMapNode>
+
+        <mvcSiteMapNode title="Actions" controller="ActionsCLAS" action="Details" preservedRouteParameters="id" >
+          <mvcSiteMapNode title="Edition d'une action CLAS" controller="ActionsCLAS" action="Edit" preservedRouteParameters="id" />
+        </mvcSiteMapNode>
           
       </mvcSiteMapNode>
     </mvcSiteMapNode>

+ 48 - 0
CD67.FicheCollege.MVC/Views/ActionsCLAS/Details.cshtml

@@ -0,0 +1,48 @@
+@using CD67.FicheCollege.MVC.Models
+@model CollegeViewModel
+
+@{
+    ViewBag.Title = "Details";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionCLAS contenu = Model.Contenu as ActionCLAS;
+}
+
+<!-- Menu de niveau 2 -->
+<div>
+    <ul id="menu-l2">
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Colleges", new { Id = Model.College_Id })">Général</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Identites", new { Id = Model.College_Id })/">Identité</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2-active" class="btn-sm" href="@Url.Action("Details", "ActionsCLAS", new { Id = Model.College_Id })/">Actions</a></li>
+    </ul>
+</div>
+
+
+<h1>@Model.College_Libelle</h1>
+
+<fieldset>
+    <legend>
+        Actions CLAS
+        @if (Model.Acces == ModeAcces.Lecture)
+        {
+            <div class="pull-right">
+                @Html.ActionLink("Modifier", "Edit", "ActionsCLAS", new { Id = Model.College_Id }, new { @class = "btn btn-default" })
+            </div>
+        }
+    </legend>
+
+    <dl class="dl-horizontal">
+        <dt>
+            @Html.DisplayNameFor(model => contenu.Action)
+        </dt>
+
+        <dd>
+            @Html.DisplayFor(model => contenu.Action)
+        </dd>
+
+        <dt>
+            @Html.DisplayNameFor(model => contenu.Commentaire)
+        </dt>
+
+        <dd style="white-space: pre-line;">@Html.DisplayFor(model => contenu.Commentaire)</dd>
+    </dl>
+</fieldset>

+ 54 - 0
CD67.FicheCollege.MVC/Views/ActionsCLAS/Edit.cshtml

@@ -0,0 +1,54 @@
+@using CD67.FicheCollege.MVC.Models
+@model CollegeViewModel
+
+@{
+    ViewBag.Title = "Edit";
+    Layout = "~/Views/Shared/_Layout.cshtml";
+    ActionCLAS contenu = Model.Contenu as ActionCLAS;
+}
+
+<h1>@Model.College_Libelle</h1>
+
+@using (Html.BeginForm())
+{
+    @Html.AntiForgeryToken()
+    
+        <fieldset>
+        <legend>
+            Actions CLAS - @Model.Acces.ToString()
+        </legend>
+        <div class="form-horizontal">
+            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
+            @Html.HiddenFor(model => contenu.College_Id)
+
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Action, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    <div class="checkbox">
+                        @Html.EditorFor(model => contenu.Action)
+                        @Html.ValidationMessageFor(model => contenu.Action, "", new { @class = "text-danger" })
+                    </div>
+                </div>
+            </div>
+
+            <div class="form-group">
+                @Html.LabelFor(model => contenu.Commentaire, htmlAttributes: new { @class = "control-label col-md-2" })
+                <div class="col-md-10">
+                    @Html.EditorFor(model => contenu.Commentaire, new { htmlAttributes = new { @class = "form-control", @rows = 10 } })
+                    @Html.ValidationMessageFor(model => contenu.Commentaire, "", new { @class = "text-danger" })
+                </div>
+            </div>
+
+            <div class="form-group">
+                <div class="col-md-offset-2 col-md-10">
+                    <input type="submit" value="@Model.Acces.EnumDisplayNameFor(MvcHtmlHelpers.DisplayValue.Prompt)" class="btn btn-default" /> |
+                    @Html.ActionLink("Annuler", "Details", new { Id = Model.College_Id })
+                </div>
+            </div>
+        </div>
+    </fieldset>
+}
+
+@section Scripts {
+    @Scripts.Render("~/bundles/jqueryval")
+}

+ 1 - 0
CD67.FicheCollege.MVC/Views/Colleges/Details.cshtml

@@ -12,6 +12,7 @@
     <ul id="menu-l2">
         <li id="li-menu-l2"><a id="a-li-menu-l2-active" class="btn-sm" href="@Url.Action("Details", "Colleges", new { Id = Model.College_Id })">Général</a></li>
         <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Identites", new { Id = Model.College_Id })/">Identité</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "ActionsCLAS", new { Id = Model.College_Id })/">Actions</a></li>
     </ul>
 </div>
 

+ 1 - 0
CD67.FicheCollege.MVC/Views/Identites/Details.cshtml

@@ -12,6 +12,7 @@
     <ul id="menu-l2">
         <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "Colleges", new { Id = Model.College_Id })">Général</a></li>
         <li id="li-menu-l2"><a id="a-li-menu-l2-active" class="btn-sm" href="@Url.Action("Details", "Identites", new { Id = Model.College_Id })/">Identité</a></li>
+        <li id="li-menu-l2"><a id="a-li-menu-l2" class="btn-sm" href="@Url.Action("Details", "ActionsCLAS", new { Id = Model.College_Id })/">Actions</a></li>
     </ul>
 </div>