diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs deleted file mode 100644 index 028322c..0000000 --- a/Controllers/HomeController.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using MyDarling.Models; - -namespace MyDarling.Controllers -{ - public class HomeController : Controller - { - private DataContext context; - public HomeController(DataContext context) - { - this.context = context; - } - public IActionResult Index() - { - return View(context.UnderwearBundles.Include(b => b.Figures)); - } - } -} \ No newline at end of file diff --git a/Views/Home/Index.cshtml b/Pages/Index.cshtml similarity index 70% rename from Views/Home/Index.cshtml rename to Pages/Index.cshtml index 54ff64d..a3ec3a5 100644 --- a/Views/Home/Index.cshtml +++ b/Pages/Index.cshtml @@ -1,7 +1,9 @@ +@page @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - +@using MyDarling.Models; +@inject DataContext context; @{ - Layout = "_Layout"; + Layout="_Layout"; } diff --git a/Views/Home/_About.cshtml b/Pages/Shared/_About.cshtml similarity index 100% rename from Views/Home/_About.cshtml rename to Pages/Shared/_About.cshtml diff --git a/Views/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml similarity index 100% rename from Views/Shared/_Layout.cshtml rename to Pages/Shared/_Layout.cshtml diff --git a/Views/Home/_Masthead.cshtml b/Pages/Shared/_Masthead.cshtml similarity index 100% rename from Views/Home/_Masthead.cshtml rename to Pages/Shared/_Masthead.cshtml diff --git a/Views/Shared/_Navigation.cshtml b/Pages/Shared/_Navigation.cshtml similarity index 100% rename from Views/Shared/_Navigation.cshtml rename to Pages/Shared/_Navigation.cshtml diff --git a/Views/Home/_Projects.cshtml b/Pages/Shared/_Projects.cshtml similarity index 79% rename from Views/Home/_Projects.cshtml rename to Pages/Shared/_Projects.cshtml index 1eb67bc..4b9a62e 100644 --- a/Views/Home/_Projects.cshtml +++ b/Pages/Shared/_Projects.cshtml @@ -1,11 +1,19 @@ -@model IQueryable; -@using System.Globalization; +@using System.Globalization +@using Microsoft.EntityFrameworkCore +@using MyDarling.Models +@inject DataContext context + +@{ + var bundles = context.UnderwearBundles + .Include(b => b.Figures) + .Where(b => b.Price != 0 && b.Figures.Count > 0) + .OrderByDescending(b => b.Id); +}
- @foreach (var bundle in @Model.Where(b => b.Price != 0 && b.Figures.Count > 0) - .OrderByDescending(b => b.Id)) + @foreach (var bundle in bundles) {
diff --git a/Views/Home/_SignUp.cshtml b/Pages/Shared/_SignUp.cshtml similarity index 100% rename from Views/Home/_SignUp.cshtml rename to Pages/Shared/_SignUp.cshtml diff --git a/Program.cs b/Program.cs index cfc572a..361be3e 100644 --- a/Program.cs +++ b/Program.cs @@ -26,12 +26,14 @@ builder.Services.Configure( opts => }); builder.Services.AddControllersWithViews(); +builder.Services.AddRazorPages(); var app = builder.Build(); app.UseStaticFiles(); app.MapControllers(); app.MapDefaultControllerRoute(); +app.MapRazorPages(); app.UseAuthentication(); app.UseAuthorization();