From 3cf5a889a77de2b9cec23c2c2e7e70528b283518 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Thu, 14 Sep 2023 10:46:35 -0400 Subject: [PATCH] Started to implement the frontend --- .../{HomeController.cs => RobotsController.cs} | 12 ++++++++---- RobotsWantedLeague/Program.cs | 2 +- RobotsWantedLeague/Views/Home/Index.cshtml | 8 -------- RobotsWantedLeague/Views/Robots/Index.cshtml | 13 +++++++++++++ .../Views/{Home => Robots}/Privacy.cshtml | 0 RobotsWantedLeague/Views/Shared/_Layout.cshtml | 9 +-------- RobotsWantedLeague/Views/_ViewImports.cshtml | 1 + 7 files changed, 24 insertions(+), 21 deletions(-) rename RobotsWantedLeague/Controllers/{HomeController.cs => RobotsController.cs} (58%) delete mode 100644 RobotsWantedLeague/Views/Home/Index.cshtml create mode 100644 RobotsWantedLeague/Views/Robots/Index.cshtml rename RobotsWantedLeague/Views/{Home => Robots}/Privacy.cshtml (100%) diff --git a/RobotsWantedLeague/Controllers/HomeController.cs b/RobotsWantedLeague/Controllers/RobotsController.cs similarity index 58% rename from RobotsWantedLeague/Controllers/HomeController.cs rename to RobotsWantedLeague/Controllers/RobotsController.cs index 5a0d0d4..fc38714 100644 --- a/RobotsWantedLeague/Controllers/HomeController.cs +++ b/RobotsWantedLeague/Controllers/RobotsController.cs @@ -1,21 +1,25 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using RobotsWantedLeague.Models; +using RobotsWantedLeague.Services; namespace RobotsWantedLeague.Controllers; -public class HomeController : Controller +public class RobotsController : Controller { - private readonly ILogger _logger; + private readonly ILogger _logger; + private readonly IRobotsService robotsService; - public HomeController(ILogger logger) + public RobotsController(ILogger logger, + IRobotsService robotsService) { _logger = logger; + this.robotsService = robotsService; } public IActionResult Index() { - return View(); + return View(robotsService.Robots); } public IActionResult Privacy() diff --git a/RobotsWantedLeague/Program.cs b/RobotsWantedLeague/Program.cs index d1668a2..7c470c8 100644 --- a/RobotsWantedLeague/Program.cs +++ b/RobotsWantedLeague/Program.cs @@ -24,6 +24,6 @@ app.UseAuthorization(); app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Robots}/{action=Index}/{id?}"); app.Run(); diff --git a/RobotsWantedLeague/Views/Home/Index.cshtml b/RobotsWantedLeague/Views/Home/Index.cshtml deleted file mode 100644 index d2d19bd..0000000 --- a/RobotsWantedLeague/Views/Home/Index.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@{ - ViewData["Title"] = "Home Page"; -} - -
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

-
diff --git a/RobotsWantedLeague/Views/Robots/Index.cshtml b/RobotsWantedLeague/Views/Robots/Index.cshtml new file mode 100644 index 0000000..ad56260 --- /dev/null +++ b/RobotsWantedLeague/Views/Robots/Index.cshtml @@ -0,0 +1,13 @@ +@{ + ViewData["Title"] = "Home Page"; +} +@model List + + +
    + @foreach (Robot robot in Model){ +
  • + @robot.Name +
  • + } +
\ No newline at end of file diff --git a/RobotsWantedLeague/Views/Home/Privacy.cshtml b/RobotsWantedLeague/Views/Robots/Privacy.cshtml similarity index 100% rename from RobotsWantedLeague/Views/Home/Privacy.cshtml rename to RobotsWantedLeague/Views/Robots/Privacy.cshtml diff --git a/RobotsWantedLeague/Views/Shared/_Layout.cshtml b/RobotsWantedLeague/Views/Shared/_Layout.cshtml index 43864f9..9cd31bf 100644 --- a/RobotsWantedLeague/Views/Shared/_Layout.cshtml +++ b/RobotsWantedLeague/Views/Shared/_Layout.cshtml @@ -18,14 +18,7 @@ diff --git a/RobotsWantedLeague/Views/_ViewImports.cshtml b/RobotsWantedLeague/Views/_ViewImports.cshtml index 381aca2..980c7db 100644 --- a/RobotsWantedLeague/Views/_ViewImports.cshtml +++ b/RobotsWantedLeague/Views/_ViewImports.cshtml @@ -1,3 +1,4 @@ @using RobotsWantedLeague @using RobotsWantedLeague.Models + @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers