summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-05-30 07:18:47 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-05-30 07:30:44 +0300
commit81c1fc0c14253457c3c4fc24735e787ace1db70b (patch)
treefed58558300250876657fe6f9b0880af6d11f9f0
parent55b30fc75acb554770dc171b5ea54ad821b81d00 (diff)
Add index razor page
-rw-r--r--Controllers/HomeController.cs19
-rw-r--r--Pages/Index.cshtml (renamed from Views/Home/Index.cshtml)6
-rw-r--r--Pages/Shared/_About.cshtml (renamed from Views/Home/_About.cshtml)0
-rw-r--r--Pages/Shared/_Layout.cshtml (renamed from Views/Shared/_Layout.cshtml)0
-rw-r--r--Pages/Shared/_Masthead.cshtml (renamed from Views/Home/_Masthead.cshtml)0
-rw-r--r--Pages/Shared/_Navigation.cshtml (renamed from Views/Shared/_Navigation.cshtml)0
-rw-r--r--Pages/Shared/_Projects.cshtml (renamed from Views/Home/_Projects.cshtml)16
-rw-r--r--Pages/Shared/_SignUp.cshtml (renamed from Views/Home/_SignUp.cshtml)0
-rw-r--r--Program.cs2
9 files changed, 18 insertions, 25 deletions
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
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";
}
<partial name="_Navigation" />
diff --git a/Views/Home/_About.cshtml b/Pages/Shared/_About.cshtml
index e7bffcb..e7bffcb 100644
--- a/Views/Home/_About.cshtml
+++ b/Pages/Shared/_About.cshtml
diff --git a/Views/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml
index 9c56830..9c56830 100644
--- a/Views/Shared/_Layout.cshtml
+++ b/Pages/Shared/_Layout.cshtml
diff --git a/Views/Home/_Masthead.cshtml b/Pages/Shared/_Masthead.cshtml
index 531a9a1..531a9a1 100644
--- a/Views/Home/_Masthead.cshtml
+++ b/Pages/Shared/_Masthead.cshtml
diff --git a/Views/Shared/_Navigation.cshtml b/Pages/Shared/_Navigation.cshtml
index 7c29a6b..7c29a6b 100644
--- a/Views/Shared/_Navigation.cshtml
+++ b/Pages/Shared/_Navigation.cshtml
diff --git a/Views/Home/_Projects.cshtml b/Pages/Shared/_Projects.cshtml
index 1eb67bc..4b9a62e 100644
--- a/Views/Home/_Projects.cshtml
+++ b/Pages/Shared/_Projects.cshtml
@@ -1,11 +1,19 @@
-@model IQueryable<MyDarling.Models.UnderwearBundle>;
-@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);
+}
<section class="projects-section bg-light" id="projects">
<div class="container px-3 px-lg-4 mt-4">
<div class="row gx-4 gx-lg-5 row-cols-2 row-cols-md-3 row-cols-xl-4 justify-content-center">
- @foreach (var bundle in @Model.Where(b => b.Price != 0 && b.Figures.Count > 0)
- .OrderByDescending(b => b.Id))
+ @foreach (var bundle in bundles)
{
<div class="col mb-5">
<div class="card h-100">
diff --git a/Views/Home/_SignUp.cshtml b/Pages/Shared/_SignUp.cshtml
index 02584f6..02584f6 100644
--- a/Views/Home/_SignUp.cshtml
+++ b/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<IdentityOptions>( opts =>
});
builder.Services.AddControllersWithViews();
+builder.Services.AddRazorPages();
var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.MapDefaultControllerRoute();
+app.MapRazorPages();
app.UseAuthentication();
app.UseAuthorization();