From 317f2e8633e4c4936cbed1ca0bc4f871c9ea3142 Mon Sep 17 00:00:00 2001 From: gorohoroh Date: Thu, 5 Jul 2018 15:48:48 +0300 Subject: [PATCH] Adding a form to create restaurants --- .../Controllers/HomeController.cs | 5 ++++ .../OdeToFoodRider/Models/CuisineType.cs | 10 ++++++++ .../OdeToFoodRider/Models/Restaurant.cs | 1 + .../OdeToFoodRider/Views/Home/Create.cshtml | 23 +++++++++++++++++++ .../OdeToFoodRider/Views/Home/Index.cshtml | 2 ++ .../Controllers/HomeController.cs | 5 ++++ .../Models/CuisineType.cs | 15 ++++++++++++ .../Models/Restaurant.cs | 1 + .../Views/Home/Create.cshtml | 16 +++++++++++++ .../Views/Home/Index.cshtml | 1 + 10 files changed, 79 insertions(+) create mode 100644 OdeToFoodRider/OdeToFoodRider/Models/CuisineType.cs create mode 100644 OdeToFoodRider/OdeToFoodRider/Views/Home/Create.cshtml create mode 100644 OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/CuisineType.cs create mode 100644 OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Create.cshtml diff --git a/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs b/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs index 0466366..d4152e5 100644 --- a/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs +++ b/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs @@ -40,5 +40,10 @@ public IActionResult Details(int id) return View(model); } + + public IActionResult Create() + { + return View(); + } } } \ No newline at end of file diff --git a/OdeToFoodRider/OdeToFoodRider/Models/CuisineType.cs b/OdeToFoodRider/OdeToFoodRider/Models/CuisineType.cs new file mode 100644 index 0000000..337693c --- /dev/null +++ b/OdeToFoodRider/OdeToFoodRider/Models/CuisineType.cs @@ -0,0 +1,10 @@ +namespace OdeToFoodRider.Models +{ + public enum CuisineType + { + None, + Italian, + French, + German + } +} \ No newline at end of file diff --git a/OdeToFoodRider/OdeToFoodRider/Models/Restaurant.cs b/OdeToFoodRider/OdeToFoodRider/Models/Restaurant.cs index 67b85df..f9393b3 100644 --- a/OdeToFoodRider/OdeToFoodRider/Models/Restaurant.cs +++ b/OdeToFoodRider/OdeToFoodRider/Models/Restaurant.cs @@ -4,5 +4,6 @@ public class Restaurant { public int Id { get; set; } public string Name { get; set; } + public CuisineType Cuisine { get; set; } } } \ No newline at end of file diff --git a/OdeToFoodRider/OdeToFoodRider/Views/Home/Create.cshtml b/OdeToFoodRider/OdeToFoodRider/Views/Home/Create.cshtml new file mode 100644 index 0000000..9ca4695 --- /dev/null +++ b/OdeToFoodRider/OdeToFoodRider/Views/Home/Create.cshtml @@ -0,0 +1,23 @@ +@using OdeToFoodRider.Models +@model OdeToFoodRider.Models.Restaurant + + + + + + Add a Restaurant + + +

Create

+ + + +@*VSRD: Rider's code analysis bug in the asp-items expression below: RSRP-469518 *@ + + + +
+ +
+ + \ No newline at end of file diff --git a/OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml b/OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml index 423c17c..645d9b1 100644 --- a/OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml +++ b/OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml @@ -27,5 +27,7 @@ } +Add Restaurant + diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs index a65fd9c..5f08014 100644 --- a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs @@ -44,5 +44,10 @@ public IActionResult Details(int id) // VSRD: Visual Studio doesn't see that the view isn't resolved and doesn't suggest to create one. return View(model); } + + public IActionResult Create() + { + return View(); + } } } diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/CuisineType.cs b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/CuisineType.cs new file mode 100644 index 0000000..8d5dead --- /dev/null +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/CuisineType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace OdeToFoodVisualStudio.Models +{ + public enum CuisineType + { + None, + Italian, + French, + German + } +} diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/Restaurant.cs b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/Restaurant.cs index 3423f6b..8c9b12d 100644 --- a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/Restaurant.cs +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Models/Restaurant.cs @@ -9,5 +9,6 @@ public class Restaurant { public int Id { get; set; } public string Name { get; set; } + public CuisineType Cuisine { get; set; } } } diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Create.cshtml b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Create.cshtml new file mode 100644 index 0000000..46a452f --- /dev/null +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Create.cshtml @@ -0,0 +1,16 @@ +@using OdeToFoodVisualStudio.Models +@model OdeToFoodVisualStudio.Models.Restaurant +@* VSRD: Visual Studio gives no import suggestions for model declaration - have to type in FQN (for which there is completion) *@ + +

Create

+ +
+ + + + @* VSRD: No import action for unreferenced CuisineType, have to manually add a @using *@ + + @* The above won't work if the select tag is empty (auto-closed: +
\ No newline at end of file diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml index 4f268c6..a387f7b 100644 --- a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml @@ -24,5 +24,6 @@ } + Add Restaurant \ No newline at end of file