diff --git a/Yavsc/Controllers/ActivityController.cs b/Yavsc/Controllers/ActivityController.cs index 2f5010b5..3aa109e7 100644 --- a/Yavsc/Controllers/ActivityController.cs +++ b/Yavsc/Controllers/ActivityController.cs @@ -6,10 +6,12 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Data.Entity; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; -using Yavsc.Models; namespace Yavsc.Controllers { + using Models; + using Models.Workflow; + [Authorize("AdministratorOnly")] public class ActivityController : Controller { diff --git a/Yavsc/Controllers/CommandFormsController.cs b/Yavsc/Controllers/CommandFormsController.cs index f8da212e..f9373536 100644 --- a/Yavsc/Controllers/CommandFormsController.cs +++ b/Yavsc/Controllers/CommandFormsController.cs @@ -4,7 +4,6 @@ using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Data.Entity; using Yavsc.Models; -using Yavsc.Models.Forms; using Yavsc.Models.Workflow; namespace Yavsc.Controllers @@ -45,11 +44,13 @@ namespace Yavsc.Controllers // GET: CommandForms/Create public IActionResult Create() { - ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name"); - ViewBag.ViewName = YavscLib.YavscConstants.Forms.Select( c => new SelectListItem { Text = c } ); + SetViewBag(); return View(); } - + private void SetViewBag(CommandForm commandForm=null) { + ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode); + ViewBag.Action = YavscLib.YavscConstants.Forms.Select( c => new SelectListItem { Text = c, Selected = commandForm?.Action == c } ); + } // POST: CommandForms/Create [HttpPost] [ValidateAntiForgeryToken] @@ -61,8 +62,7 @@ namespace Yavsc.Controllers await _context.SaveChangesAsync(); return RedirectToAction("Index"); } - ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode); - ViewData["FormId"] = new SelectList(_context.Set