From a169f38baf2fd877267830ed00c03dc2ce7eb0c1 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 23 Jan 2017 23:52:47 +0100 Subject: [PATCH] cleanings --- Yavsc/Controllers/CommandFormsController.cs | 127 ++++++++++++++++++ ...0122160343_circlesMemberRefact.Designer.cs | 1 - .../20170122160343_circlesMemberRefact.cs | 2 - .../ApplicationDbContextModelSnapshot.cs | 2 - Yavsc/Models/Forms/Form.cs | 4 +- .../CirclesControlViewComponent.cs | 5 +- Yavsc/Views/CommandForms/Create.cshtml | 45 +++++++ Yavsc/Views/CommandForms/Delete.cshtml | 34 +++++ Yavsc/Views/CommandForms/Details.cshtml | 30 +++++ Yavsc/Views/CommandForms/Edit.cshtml | 47 +++++++ Yavsc/Views/CommandForms/Index.cshtml | 38 ++++++ Yavsc/Views/Shared/_Layout.cshtml | 2 - YavscLib/ICircleAuthorized.cs | 4 - 13 files changed, 323 insertions(+), 18 deletions(-) create mode 100644 Yavsc/Controllers/CommandFormsController.cs create mode 100644 Yavsc/Views/CommandForms/Create.cshtml create mode 100644 Yavsc/Views/CommandForms/Delete.cshtml create mode 100644 Yavsc/Views/CommandForms/Details.cshtml create mode 100644 Yavsc/Views/CommandForms/Edit.cshtml create mode 100644 Yavsc/Views/CommandForms/Index.cshtml diff --git a/Yavsc/Controllers/CommandFormsController.cs b/Yavsc/Controllers/CommandFormsController.cs new file mode 100644 index 00000000..9a6614d0 --- /dev/null +++ b/Yavsc/Controllers/CommandFormsController.cs @@ -0,0 +1,127 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Rendering; +using Microsoft.Data.Entity; +using Yavsc.Models; +using Yavsc.Models.Workflow; + +namespace Yavsc.Controllers +{ + public class CommandFormsController : Controller + { + private ApplicationDbContext _context; + + public CommandFormsController(ApplicationDbContext context) + { + _context = context; + } + + // GET: CommandForms + public async Task Index() + { + var applicationDbContext = _context.CommandForm.Include(c => c.Context); + return View(await applicationDbContext.ToListAsync()); + } + + // GET: CommandForms/Details/5 + public async Task Details(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id); + if (commandForm == null) + { + return HttpNotFound(); + } + + return View(commandForm); + } + + // GET: CommandForms/Create + public IActionResult Create() + { + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context"); + return View(); + } + + // POST: CommandForms/Create + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Create(CommandForm commandForm) + { + if (ModelState.IsValid) + { + _context.CommandForm.Add(commandForm); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode); + return View(commandForm); + } + + // GET: CommandForms/Edit/5 + public async Task Edit(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id); + if (commandForm == null) + { + return HttpNotFound(); + } + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode); + return View(commandForm); + } + + // POST: CommandForms/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(CommandForm commandForm) + { + if (ModelState.IsValid) + { + _context.Update(commandForm); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode); + return View(commandForm); + } + + // GET: CommandForms/Delete/5 + [ActionName("Delete")] + public async Task Delete(string id) + { + if (id == null) + { + return HttpNotFound(); + } + + CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id); + if (commandForm == null) + { + return HttpNotFound(); + } + + return View(commandForm); + } + + // POST: CommandForms/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(string id) + { + CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id); + _context.CommandForm.Remove(commandForm); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + } +} diff --git a/Yavsc/Migrations/20170122160343_circlesMemberRefact.Designer.cs b/Yavsc/Migrations/20170122160343_circlesMemberRefact.Designer.cs index c681eef3..ba71277c 100644 --- a/Yavsc/Migrations/20170122160343_circlesMemberRefact.Designer.cs +++ b/Yavsc/Migrations/20170122160343_circlesMemberRefact.Designer.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Metadata; using Microsoft.Data.Entity.Migrations; using Yavsc.Models; diff --git a/Yavsc/Migrations/20170122160343_circlesMemberRefact.cs b/Yavsc/Migrations/20170122160343_circlesMemberRefact.cs index a57287df..2b553a6e 100644 --- a/Yavsc/Migrations/20170122160343_circlesMemberRefact.cs +++ b/Yavsc/Migrations/20170122160343_circlesMemberRefact.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Microsoft.Data.Entity.Migrations; namespace Yavsc.Migrations diff --git a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs index 0dec716c..01df740d 100644 --- a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,8 +1,6 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Migrations; using Yavsc.Models; namespace Yavsc.Migrations diff --git a/Yavsc/Models/Forms/Form.cs b/Yavsc/Models/Forms/Form.cs index 0aedd5d2..1e1c71c3 100644 --- a/Yavsc/Models/Forms/Form.cs +++ b/Yavsc/Models/Forms/Form.cs @@ -1,10 +1,8 @@ -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Yavsc.Models.Forms { - using Interfaces; - + public class Form { [Key] diff --git a/Yavsc/ViewComponents/CirclesControlViewComponent.cs b/Yavsc/ViewComponents/CirclesControlViewComponent.cs index 72bdab7e..c5b54711 100644 --- a/Yavsc/ViewComponents/CirclesControlViewComponent.cs +++ b/Yavsc/ViewComponents/CirclesControlViewComponent.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using System.Web.UI.WebControls; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Rendering; using Yavsc.Models; @@ -18,7 +15,7 @@ namespace Yavsc.ViewComponents { this.dbContext = dbContext; } - public async Task InvokeAsync (ICircleAuthorized target) + public IViewComponentResult InvokeAsync (ICircleAuthorized target) { var oid = target.GetOwnerId(); ViewBag.ACL = dbContext.Circle.Where( diff --git a/Yavsc/Views/CommandForms/Create.cshtml b/Yavsc/Views/CommandForms/Create.cshtml new file mode 100644 index 00000000..de6380a4 --- /dev/null +++ b/Yavsc/Views/CommandForms/Create.cshtml @@ -0,0 +1,45 @@ +@model Yavsc.Models.Workflow.CommandForm + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +
+
+

CommandForm

+
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/CommandForms/Delete.cshtml b/Yavsc/Views/CommandForms/Delete.cshtml new file mode 100644 index 00000000..f0a2c507 --- /dev/null +++ b/Yavsc/Views/CommandForms/Delete.cshtml @@ -0,0 +1,34 @@ +@model Yavsc.Models.Workflow.CommandForm + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

CommandForm

+
+
+
+ @Html.DisplayNameFor(model => model.Summary) +
+
+ @Html.DisplayFor(model => model.Summary) +
+
+ @Html.DisplayNameFor(model => model.Title) +
+
+ @Html.DisplayFor(model => model.Title) +
+
+ +
+
+ | + Back to List +
+
+
diff --git a/Yavsc/Views/CommandForms/Details.cshtml b/Yavsc/Views/CommandForms/Details.cshtml new file mode 100644 index 00000000..dc3ba2ba --- /dev/null +++ b/Yavsc/Views/CommandForms/Details.cshtml @@ -0,0 +1,30 @@ +@model Yavsc.Models.Workflow.CommandForm + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

CommandForm

+
+
+
+ @Html.DisplayNameFor(model => model.Summary) +
+
+ @Html.DisplayFor(model => model.Summary) +
+
+ @Html.DisplayNameFor(model => model.Title) +
+
+ @Html.DisplayFor(model => model.Title) +
+
+
+

+ Edit | + Back to List +

diff --git a/Yavsc/Views/CommandForms/Edit.cshtml b/Yavsc/Views/CommandForms/Edit.cshtml new file mode 100644 index 00000000..15e6c5fc --- /dev/null +++ b/Yavsc/Views/CommandForms/Edit.cshtml @@ -0,0 +1,47 @@ +@model Yavsc.Models.Workflow.CommandForm + +@{ + ViewData["Title"] = "Edit"; +} + +

Edit

+ +
+
+

CommandForm

+
+
+ +
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + diff --git a/Yavsc/Views/CommandForms/Index.cshtml b/Yavsc/Views/CommandForms/Index.cshtml new file mode 100644 index 00000000..ee1fb197 --- /dev/null +++ b/Yavsc/Views/CommandForms/Index.cshtml @@ -0,0 +1,38 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+ Create New +

+ + + + + + + +@foreach (var item in Model) { + + + + + +} +
+ @Html.DisplayNameFor(model => model.Summary) + + @Html.DisplayNameFor(model => model.Title) +
+ @Html.DisplayFor(modelItem => item.Summary) + + @Html.DisplayFor(modelItem => item.Title) + + Edit | + Details | + Delete +
diff --git a/Yavsc/Views/Shared/_Layout.cshtml b/Yavsc/Views/Shared/_Layout.cshtml index b7a22cb3..a86619f9 100755 --- a/Yavsc/Views/Shared/_Layout.cshtml +++ b/Yavsc/Views/Shared/_Layout.cshtml @@ -15,7 +15,6 @@ - @@ -29,7 +28,6 @@ asp-fallback-src="~/bower_components/bootstrap/dist/js/bootstrap.min.js" asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"> - diff --git a/YavscLib/ICircleAuthorized.cs b/YavscLib/ICircleAuthorized.cs index 48517ff6..f68c1ee3 100644 --- a/YavscLib/ICircleAuthorized.cs +++ b/YavscLib/ICircleAuthorized.cs @@ -1,7 +1,3 @@ - - -using System.Collections.Generic; - namespace YavscLib { public interface ICircleAuthorized