diff --git a/GameLibrary/Database.db b/GameLibrary/Database.db index 9a47220..9335ca8 100644 Binary files a/GameLibrary/Database.db and b/GameLibrary/Database.db differ diff --git a/GameLibrary/Database.db-shm b/GameLibrary/Database.db-shm index 1846484..fe9ac28 100644 Binary files a/GameLibrary/Database.db-shm and b/GameLibrary/Database.db-shm differ diff --git a/GameLibrary/Database.db-wal b/GameLibrary/Database.db-wal index f9e85be..e69de29 100644 Binary files a/GameLibrary/Database.db-wal and b/GameLibrary/Database.db-wal differ diff --git a/GameLibrary/Pages/Games/Index.cshtml b/GameLibrary/Pages/Games/Index.cshtml new file mode 100644 index 0000000..c545468 --- /dev/null +++ b/GameLibrary/Pages/Games/Index.cshtml @@ -0,0 +1,28 @@ +@page +@model GameLibrary.Pages.Games.IndexModel +@{ + ViewData["Title"] = "Welcome to GAMELIB"; +} + +

Welcome to GAMELIB

+ +
+

Game List

+
+ @foreach (var game in Model.Games) + { +
+
+ @game.Title +
+
@game.Title
+

@game.Description.Substring(0, Math.Min(100, @game.Description.Length)) + "..." +

+ View Details +
+
+
+ } +
+
diff --git a/GameLibrary/Pages/Games/Index.cshtml.cs b/GameLibrary/Pages/Games/Index.cshtml.cs new file mode 100644 index 0000000..d007ea2 --- /dev/null +++ b/GameLibrary/Pages/Games/Index.cshtml.cs @@ -0,0 +1,41 @@ +// Copyright 2024 Web.Tech. Group17 +// +// Licensed under the Apache License, Version 2.0 (the "License"): +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +using GameLibrary.Data; +using GameLibrary.Models; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; + +namespace GameLibrary.Pages.Games; + +public class IndexModel : PageModel +{ + private readonly ApplicationDbContext _context; + + public IndexModel(ApplicationDbContext context) + { + _context = context; + } + + public IList Games { get; set; } = new List(); + + public async Task OnGetAsync() + { + Games = await _context.Games + .OrderByDescending(g => g.Rating) + .ThenByDescending(g => g.ReleaseDate) + .ToListAsync(); + } +} diff --git a/GameLibrary/Pages/Index.cshtml b/GameLibrary/Pages/Index.cshtml index f9d5130..f9ff8d4 100644 --- a/GameLibrary/Pages/Index.cshtml +++ b/GameLibrary/Pages/Index.cshtml @@ -1,28 +1,10 @@ @page -@model GameLibrary.Pages.IndexModel +@model IndexModel @{ - ViewData["Title"] = "Welcome to GAMELIB"; + ViewData["Title"] = "Home page"; } -

Welcome to GAMELIB

- -
-

Game List

-
- @foreach (var game in Model.Games) - { -
-
- @game.Title -
-
@game.Title
-

@game.Description.Substring(0, Math.Min(100, @game.Description.Length)) + "..." -

- View Details -
-
-
- } -
+
+

Welcome

+

Learn about building Web apps with ASP.NET Core.

diff --git a/GameLibrary/Pages/Index.cshtml.cs b/GameLibrary/Pages/Index.cshtml.cs index 712190a..35000e6 100644 --- a/GameLibrary/Pages/Index.cshtml.cs +++ b/GameLibrary/Pages/Index.cshtml.cs @@ -12,30 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. - -using GameLibrary.Data; -using GameLibrary.Models; using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.EntityFrameworkCore; namespace GameLibrary.Pages; public class IndexModel : PageModel { - private readonly ApplicationDbContext _context; + private readonly ILogger _logger; - public IndexModel(ApplicationDbContext context) + public IndexModel(ILogger logger) { - _context = context; + _logger = logger; } - public IList Games { get; set; } = new List(); - - public async Task OnGetAsync() + public void OnGet() { - Games = await _context.Games - .OrderByDescending(g => g.Rating) - .ThenByDescending(g => g.ReleaseDate) - .ToListAsync(); + } } diff --git a/GameLibrary/Pages/Shared/_Layout.cshtml b/GameLibrary/Pages/Shared/_Layout.cshtml index cef1978..74956ff 100644 --- a/GameLibrary/Pages/Shared/_Layout.cshtml +++ b/GameLibrary/Pages/Shared/_Layout.cshtml @@ -22,7 +22,9 @@