From bc28909662838fbf7db9dd449c9341d29c95fbc8 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 15 Jan 2017 18:49:48 +0100 Subject: [PATCH] collaborateurs et home page --- Yavsc/Controllers/CoWorkingController.cs | 131 +++++++++++++++++++++++ Yavsc/Controllers/HomeController.cs | 2 +- Yavsc/Views/CoWorking/Create.cshtml | 42 ++++++++ Yavsc/Views/CoWorking/Delete.cshtml | 22 ++++ Yavsc/Views/CoWorking/Details.cshtml | 18 ++++ Yavsc/Views/CoWorking/Edit.cshtml | 45 ++++++++ Yavsc/Views/CoWorking/Index.cshtml | 26 +++++ Yavsc/Views/Home/Index.cshtml | 70 +++++------- 8 files changed, 309 insertions(+), 47 deletions(-) create mode 100644 Yavsc/Controllers/CoWorkingController.cs create mode 100644 Yavsc/Views/CoWorking/Create.cshtml create mode 100644 Yavsc/Views/CoWorking/Delete.cshtml create mode 100644 Yavsc/Views/CoWorking/Details.cshtml create mode 100644 Yavsc/Views/CoWorking/Edit.cshtml create mode 100644 Yavsc/Views/CoWorking/Index.cshtml diff --git a/Yavsc/Controllers/CoWorkingController.cs b/Yavsc/Controllers/CoWorkingController.cs new file mode 100644 index 00000000..583fd25f --- /dev/null +++ b/Yavsc/Controllers/CoWorkingController.cs @@ -0,0 +1,131 @@ +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 CoWorkingController : Controller + { + private ApplicationDbContext _context; + + public CoWorkingController(ApplicationDbContext context) + { + _context = context; + } + + // GET: CoWorking + public async Task Index() + { + var applicationDbContext = _context.WorkflowProviders.Include(c => c.Performer).Include(c => c.WorkingFor); + return View(await applicationDbContext.ToListAsync()); + } + + // GET: CoWorking/Details/5 + public async Task Details(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id); + if (coWorking == null) + { + return HttpNotFound(); + } + + return View(coWorking); + } + + // GET: CoWorking/Create + public IActionResult Create() + { + ViewBag.PerformerId = _context.Performers.Select( p=> new SelectListItem { Value = p.PerformerId, Text = p.Performer.UserName}); + ViewBag.WorkingForId = new SelectList(_context.Users, "Id", "UserName"); + return View(); + } + + // POST: CoWorking/Create + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Create(CoWorking coWorking) + { + if (ModelState.IsValid) + { + _context.WorkflowProviders.Add(coWorking); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId); + ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId); + return View(coWorking); + } + + // GET: CoWorking/Edit/5 + public async Task Edit(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id); + if (coWorking == null) + { + return HttpNotFound(); + } + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId); + ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId); + return View(coWorking); + } + + // POST: CoWorking/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(CoWorking coWorking) + { + if (ModelState.IsValid) + { + _context.Update(coWorking); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId); + ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId); + return View(coWorking); + } + + // GET: CoWorking/Delete/5 + [ActionName("Delete")] + public async Task Delete(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + + CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id); + if (coWorking == null) + { + return HttpNotFound(); + } + + return View(coWorking); + } + + // POST: CoWorking/Delete/5 + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task DeleteConfirmed(long id) + { + CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id); + _context.WorkflowProviders.Remove(coWorking); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } + } +} diff --git a/Yavsc/Controllers/HomeController.cs b/Yavsc/Controllers/HomeController.cs index 1bd7e4e2..1fef45de 100644 --- a/Yavsc/Controllers/HomeController.cs +++ b/Yavsc/Controllers/HomeController.cs @@ -30,7 +30,7 @@ namespace Yavsc.Controllers public IActionResult Index() { - return View(); + return View(DbContext.Activities); } public IActionResult About() diff --git a/Yavsc/Views/CoWorking/Create.cshtml b/Yavsc/Views/CoWorking/Create.cshtml new file mode 100644 index 00000000..ccdb8655 --- /dev/null +++ b/Yavsc/Views/CoWorking/Create.cshtml @@ -0,0 +1,42 @@ +@model Yavsc.Models.Workflow.CoWorking + +@{ + ViewData["Title"] = "Create"; +} + +

Create

+ +
+
+

CoWorking

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ + + +@section Scripts { + + + +} diff --git a/Yavsc/Views/CoWorking/Delete.cshtml b/Yavsc/Views/CoWorking/Delete.cshtml new file mode 100644 index 00000000..4a97291f --- /dev/null +++ b/Yavsc/Views/CoWorking/Delete.cshtml @@ -0,0 +1,22 @@ +@model Yavsc.Models.Workflow.CoWorking + +@{ + ViewData["Title"] = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

CoWorking

+
+
+
+ +
+
+ | + Back to List +
+
+
diff --git a/Yavsc/Views/CoWorking/Details.cshtml b/Yavsc/Views/CoWorking/Details.cshtml new file mode 100644 index 00000000..e3f1e954 --- /dev/null +++ b/Yavsc/Views/CoWorking/Details.cshtml @@ -0,0 +1,18 @@ +@model Yavsc.Models.Workflow.CoWorking + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

CoWorking

+
+
+
+
+

+ Edit | + Back to List +

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

Edit

+ +
+
+

CoWorking

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

Index

+ +

+ Create New +

+ + + + + +@foreach (var item in Model) { + + + +} +
+ Edit | + Details | + Delete +
diff --git a/Yavsc/Views/Home/Index.cshtml b/Yavsc/Views/Home/Index.cshtml index cf2d8089..b7c4d56b 100755 --- a/Yavsc/Views/Home/Index.cshtml +++ b/Yavsc/Views/Home/Index.cshtml @@ -4,61 +4,39 @@