From 1a96616699ab41bf6343bc1acc45a836c3e6caf3 Mon Sep 17 00:00:00 2001 From: Paweł Bernaciak Date: Fri, 22 Dec 2023 16:02:41 +0100 Subject: Backup --- CoreWiki/Pages/Edit.cshtml.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'CoreWiki/Pages/Edit.cshtml.cs') diff --git a/CoreWiki/Pages/Edit.cshtml.cs b/CoreWiki/Pages/Edit.cshtml.cs index e3b11c2..46920cb 100644 --- a/CoreWiki/Pages/Edit.cshtml.cs +++ b/CoreWiki/Pages/Edit.cshtml.cs @@ -25,14 +25,9 @@ namespace CoreWiki.Pages [BindProperty] public Article Article { get; set; } = default!; - public async Task OnGetAsync(string id) + public async Task OnGetAsync(string slug) { - if (id == null || _context.Articles == null) - { - return NotFound(); - } - - var article = await _context.Articles.FirstOrDefaultAsync(m => m.Topic == id); + var article = await _context.Articles.FirstOrDefaultAsync(m => m.Slug == slug); if (article == null) { return NotFound(); @@ -40,9 +35,7 @@ namespace CoreWiki.Pages Article = article; return Page(); } - - // To protect from overposting attacks, enable the specific properties you want to bind to. - // For more details, see https://aka.ms/RazorPagesCRUD. + public async Task OnPostAsync() { if (!ModelState.IsValid) @@ -69,12 +62,12 @@ namespace CoreWiki.Pages } } - return Redirect($"./{(Article.Topic == "HomePage" ? "" : Article.Topic)}"); + return Redirect($"/{(Article.Slug == "home-page" ? "" : Article.Slug)}"); } private bool ArticleExists(string id) { - return (_context.Articles?.Any(e => e.Topic == id)).GetValueOrDefault(); + return (_context.Articles?.Any(e => e.Slug == id)).GetValueOrDefault(); } } } -- cgit v1.2.3