From 72d36e35729a25f745b41b92a6295a371defe669 Mon Sep 17 00:00:00 2001 From: Carly Langlois Date: Tue, 21 Apr 2020 10:46:29 -0500 Subject: [PATCH 01/42] views exercises solution --- .../Controllers/EventsController.cs | 6 ++--- CodingEventsDemo/Views/Events/Add.cshtml | 3 +++ CodingEventsDemo/Views/Events/Index.cshtml | 26 ++++++++++++++----- CodingEventsDemo/Views/Shared/_Layout.cshtml | 7 ++--- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CodingEventsDemo/Controllers/EventsController.cs b/CodingEventsDemo/Controllers/EventsController.cs index 16edaf58..4ce8bbcb 100644 --- a/CodingEventsDemo/Controllers/EventsController.cs +++ b/CodingEventsDemo/Controllers/EventsController.cs @@ -11,7 +11,7 @@ namespace coding_events_practice.Controllers public class EventsController : Controller { - static private List Events = new List(); + static private Dictionary Events = new Dictionary(); // GET: // public IActionResult Index() @@ -28,9 +28,9 @@ public IActionResult Add() [HttpPost] [Route("Events/Add")] - public IActionResult NewEvent(string name) + public IActionResult NewEvent(string name, string desc) { - Events.Add(name); + Events.Add(name, desc); return Redirect("/Events"); } diff --git a/CodingEventsDemo/Views/Events/Add.cshtml b/CodingEventsDemo/Views/Events/Add.cshtml index 0010854d..cf4b0065 100644 --- a/CodingEventsDemo/Views/Events/Add.cshtml +++ b/CodingEventsDemo/Views/Events/Add.cshtml @@ -1,6 +1,9 @@ 

Add Event

+ + +
diff --git a/CodingEventsDemo/Views/Events/Index.cshtml b/CodingEventsDemo/Views/Events/Index.cshtml index 7278447c..8c24e17d 100644 --- a/CodingEventsDemo/Views/Events/Index.cshtml +++ b/CodingEventsDemo/Views/Events/Index.cshtml @@ -8,10 +8,24 @@ {

No events yet!

} +else +{ + + + + + + @foreach (KeyValuePair evt in ViewBag.events) + { + + + + + } +
+ Name + + Description +
@evt.Key@evt.Value
+} -
    - @foreach (string meeting in ViewBag.events) - { -
  • @meeting
  • - } -
diff --git a/CodingEventsDemo/Views/Shared/_Layout.cshtml b/CodingEventsDemo/Views/Shared/_Layout.cshtml index 36ea09b8..56938243 100644 --- a/CodingEventsDemo/Views/Shared/_Layout.cshtml +++ b/CodingEventsDemo/Views/Shared/_Layout.cshtml @@ -11,7 +11,7 @@