0
0

Add index razor page

This commit is contained in:
Sergey Chebotar 2023-05-30 07:18:47 +03:00
parent 55b30fc75a
commit 81c1fc0c14
9 changed files with 18 additions and 25 deletions

View File

@ -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));
}
}
}

View File

@ -1,7 +1,9 @@
@page
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@using MyDarling.Models;
@inject DataContext context;
@{
Layout = "_Layout";
Layout="_Layout";
}
<partial name="_Navigation" />

View File

@ -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">

View File

@ -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();