Files
kochstube/webapp/Kochstube/Pages/Index.cshtml.cs
T

35 lines
934 B
C#
Executable File

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Kochstube.Models;
using Kochstube.Services;
namespace Kochstube.Pages;
public class IndexModel : PageModel
{
private readonly RezeptService _service;
public IndexModel(RezeptService service) => _service = service;
public List<Rezept> Rezepte { get; set; } = [];
public List<string> AlleTags { get; set; } = [];
public List<string> AlleKategorien { get; set; } = [];
[BindProperty(SupportsGet = true)]
public string? Q { get; set; }
[BindProperty(SupportsGet = true)]
public string? Tag { get; set; }
[BindProperty(SupportsGet = true)]
public string? Kategorie { get; set; }
public void OnGet()
{
AlleTags = _service.GetAllTags();
AlleKategorien = _service.GetAllKategorien();
Rezepte = _service.Search(Q, Tag, Kategorie);
ViewData["Title"] = "Rezepte";
}
}