-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@page | ||
@model GameLibrary.Pages.Games.IndexModel | ||
@{ | ||
ViewData["Title"] = "Welcome to GAMELIB"; | ||
} | ||
|
||
<h1 style="color: #FFD43B;">Welcome to GAMELIB</h1> | ||
|
||
<div> | ||
<h2>Game List</h2> | ||
<div class="row"> | ||
@foreach (var game in Model.Games) | ||
{ | ||
<div class="col-md-4"> | ||
<div class="card" style="margin-bottom: 20px;"> | ||
<img src="@game.ImageUrl" class="card-img-top" alt="@game.Title" | ||
style="height: 200px; object-fit: cover;" /> | ||
<div class="card-body"> | ||
<h5 class="card-title">@game.Title</h5> | ||
<p class="card-text">@game.Description.Substring(0, Math.Min(100, @game.Description.Length)) + "..." | ||
</p> | ||
<a href="/Games/[email protected]" class="btn btn-primary">View Details</a> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Game> Games { get; set; } = new List<Game>(); | ||
|
||
public async Task OnGetAsync() | ||
{ | ||
Games = await _context.Games | ||
.OrderByDescending(g => g.Rating) | ||
.ThenByDescending(g => g.ReleaseDate) | ||
.ToListAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,10 @@ | ||
@page | ||
@model GameLibrary.Pages.IndexModel | ||
@model IndexModel | ||
@{ | ||
ViewData["Title"] = "Welcome to GAMELIB"; | ||
ViewData["Title"] = "Home page"; | ||
} | ||
|
||
<h1 style="color: #FFD43B;">Welcome to GAMELIB</h1> | ||
|
||
<div> | ||
<h2>Game List</h2> | ||
<div class="row"> | ||
@foreach (var game in Model.Games) | ||
{ | ||
<div class="col-md-4"> | ||
<div class="card" style="margin-bottom: 20px;"> | ||
<img src="@game.ImageUrl" class="card-img-top" alt="@game.Title" | ||
style="height: 200px; object-fit: cover;" /> | ||
<div class="card-body"> | ||
<h5 class="card-title">@game.Title</h5> | ||
<p class="card-text">@game.Description.Substring(0, Math.Min(100, @game.Description.Length)) + "..." | ||
</p> | ||
<a href="/Games/[email protected]" class="btn btn-primary">View Details</a> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
<div class="text-center"> | ||
<h1 class="display-4">Welcome</h1> | ||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters