Skip to content

Commit

Permalink
Fix empty random quote
Browse files Browse the repository at this point in the history
  • Loading branch information
spech66 committed Jul 24, 2024
1 parent 5486079 commit 1db590f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions LifelogBb/Controllers/QuotesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public async Task<IActionResult> Random()
{
var quotes = from s in _context.Quotes select s;
var randomQuote = await quotes.OrderBy(r => EF.Functions.Random()).Take(1).FirstOrDefaultAsync();
if(randomQuote == null)
{
return RedirectToAction("Index");
}
return View(randomQuote);
}

Expand Down

0 comments on commit 1db590f

Please sign in to comment.