From 00c3b32e2db200a2f42396ac7f8381704ec97268 Mon Sep 17 00:00:00 2001 From: Paweł Bernaciak Date: Fri, 10 Feb 2023 16:19:46 +0100 Subject: Initial Commit --- CoreWiki/Pages/LatestChanges.cshtml.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 CoreWiki/Pages/LatestChanges.cshtml.cs (limited to 'CoreWiki/Pages/LatestChanges.cshtml.cs') diff --git a/CoreWiki/Pages/LatestChanges.cshtml.cs b/CoreWiki/Pages/LatestChanges.cshtml.cs new file mode 100644 index 0000000..d750417 --- /dev/null +++ b/CoreWiki/Pages/LatestChanges.cshtml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; +using CoreWiki.Models; + +namespace CoreWiki.Pages +{ + public class LatestChangesModel : PageModel + { + private readonly CoreWiki.Models.ApplicationDbContext _context; + + public LatestChangesModel(CoreWiki.Models.ApplicationDbContext context) + { + _context = context; + } + + public IList
Article { get;set; } = default!; + + public async Task OnGetAsync() + { + if (_context.Articles != null) + { + Article = await _context.Articles.OrderByDescending(a => a.Published).Take(10).ToListAsync(); + } + } + } +} -- cgit v1.2.3