diff options
Diffstat (limited to 'CoreWiki/Pages/Edit.cshtml.cs')
| -rw-r--r-- | CoreWiki/Pages/Edit.cshtml.cs | 17 |
1 files changed, 5 insertions, 12 deletions
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<IActionResult> OnGetAsync(string id)
+ public async Task<IActionResult> 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<IActionResult> 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();
}
}
}
|
