Skip to content

Commit

Permalink
Merge branch 'Auth-2.0-Extension'
Browse files Browse the repository at this point in the history
  • Loading branch information
RespectMathias committed Dec 8, 2024
1 parent 0df5021 commit 0205353
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 152 deletions.
Binary file modified GameLibrary/Database.db
Binary file not shown.
Binary file modified GameLibrary/Database.db-shm
Binary file not shown.
Binary file modified GameLibrary/Database.db-wal
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
// 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 System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace GameLibrary.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
Expand Down
117 changes: 71 additions & 46 deletions GameLibrary/Pages/Admin/Games/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,83 @@
@model GameLibrary.Pages.Admin.Games.CreateModel

@{
ViewData["Title"] = "Create";
ViewData["Title"] = "Create";
}

<body style=" color:#FFD43B;">

<body style="color:#FFD43B;">
<header>
<h1>Create Game</h1>
</header>
<!--Create Game Details Section-->
<div class="container py-2">
<div class="row">
<div class="col-lg-6 col-md-12">
<form method="post" enctype="multipart/form-data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>

<div class="row container">
<div class="col-md-4">
<form method="post" enctype="multipart/form-data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>

<div class="form-group">
<label asp-for="Game!.Title" class="control-label">Title</label>
<input asp-for="Game!.Title" class="form-control" />
<span asp-validation-for="Game!.Title" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="ImageFile" class="control-label">Image</label>
<input type="file" asp-for="ImageFile" class="form-control" onchange="previewImage(event)" />
<span asp-validation-for="ImageFile" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Genre" class="control-label">Genre</label>
<input asp-for="Game!.Genre" class="form-control" />
<span asp-validation-for="Game!.Genre" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.ReleaseDate.Date" class="control-label">Release Date</label>
<input asp-for="Game!.ReleaseDate.Date" class="form-control" />
<span asp-validation-for="Game!.ReleaseDate.Date" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Description" class="control-label">Description</label>
<textarea asp-for="Game!.Description" class="form-control"></textarea>
<span asp-validation-for="Game!.Description" class="text-danger"></span>
</div>

<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" style="background-color: #420599; color: #FFD43B;" />
<a asp-page="Index" class="btn" style="background-color: #420599; color: #FFD43B;">Back to List</a>
</div>
</form>
</div>
<div class="col-md-4">
<img id="imagePreview" src="#" class="img-thumbnail" style="display:none;" />
<div class="form-group">
<label asp-for="Game!.Title" class="control-label">Title:</label>
<input asp-for="Game!.Title" class="form-control" required />
<span asp-validation-for="Game!.Title" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="ImageFile" class="control-label">Image:</label>
<input type="file" asp-for="ImageFile" class="form-control" onchange="previewImage(event)" required />
<span asp-validation-for="ImageFile" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Genre" class="control-label">Genre:</label>
<input asp-for="Game!.Genre" class="form-control" required />
<span asp-validation-for="Game!.Genre" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.ReleaseDate" class="control-label">Release Date:</label>
<input asp-for="Game!.ReleaseDate" class="form-control" type="date" required />
<span asp-validation-for="Game!.ReleaseDate" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Developer" class="control-label">Developer:</label>
<input asp-for="Game!.Developer" class="form-control" />
<span asp-validation-for="Game!.Developer" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Publisher" class="control-label">Publisher:</label>
<input asp-for="Game!.Publisher" class="form-control" />
<span asp-validation-for="Game!.Publisher" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Platform" class="control-label">Platform:</label>
<input asp-for="Game!.Platform" class="form-control" />
<span asp-validation-for="Game!.Platform" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Price" class="control-label">Price:</label>
<input asp-for="Game!.Price" class="form-control" type="number" step="0.01" />
<span asp-validation-for="Game!.Price" class="text-danger"></span>
</div>

<div class="form-group d-flex flex-column">
<label asp-for="Game!.Description" class="control-label">Description:</label>
<textarea asp-for="Game!.Description" class="form-control flex-grow-1"></textarea>
<span asp-validation-for="Game!.Description" class="text-danger"></span>
</div>

<div>
<input type="submit" value="Create" class="btn btn-primary" style="background-color: #420599; color: #FFD43B;" />
<a asp-page="Index" class="btn" style="background-color: #420599; color: #FFD43B;">Back to List</a>
</div>
</form>
</div>
<div class="col-lg-6 col-md-12 py-2 d-flex justify-content-center align-items-center">
<img id="imagePreview" src="#" class="img-thumbnail" style="display:none; width: 400px; height: auto;" />
</div>
</div>
</div>
</body>
2 changes: 1 addition & 1 deletion GameLibrary/Pages/Admin/Games/Create.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<IActionResult> OnPostAsync(Guid gameId)
}

// Check file extension
var allowedExtensions = new[] { ".jpg", ".jpeg", ".png" };
var allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".webp" };
var extension = Path.GetExtension(ImageFile.FileName);
if (!allowedExtensions.Contains(extension.ToLower()))
{
Expand Down
2 changes: 1 addition & 1 deletion GameLibrary/Pages/Admin/Games/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Model.Game!.Genre
</dd>
<dt class="col-sm-4" style="color:#FFD43B;">
Release Date:
Release:
</dt>
<dd class="col-sm-8">
@Model.Game!.ReleaseDate.ToString("MMMM dd, yyyy")
Expand Down
39 changes: 31 additions & 8 deletions GameLibrary/Pages/Admin/Games/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,50 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Game!.Id" />
<div class="form-group">
<label asp-for="Game!.Title" class="control-label">Title</label>
<label asp-for="Game!.Title" class="control-label">Title:</label>
<input asp-for="Game!.Title" class="form-control" />
<span asp-validation-for="Game!.Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ImageFile" class="control-label">New Image</label>
<label asp-for="ImageFile" class="control-label">New Image:</label>
<input type="file" asp-for="ImageFile" class="form-control" onchange="previewImage(event)" />
<span asp-validation-for="ImageFile" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Game!.Genre" class="control-label">Genre</label>
<label asp-for="Game!.Genre" class="control-label">Genre:</label>
<input asp-for="Game!.Genre" class="form-control" />
<span asp-validation-for="Game!.Genre" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Game!.ReleaseDate.Date" class="control-label">Release Date</label>
<input asp-for="Game!.ReleaseDate.Date" class="form-control" />
<span asp-validation-for="Game!.ReleaseDate.Date" class="text-danger"></span>
</div>
<label asp-for="Game!.ReleaseDate" class="control-label">Release Date:</label>
<input asp-for="Game!.ReleaseDate" class="form-control" type="date" required />
<span asp-validation-for="Game!.ReleaseDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Game!.Developer" class="control-label">Developer:</label>
<input asp-for="Game!.Developer" class="form-control" />
<span asp-validation-for="Game!.Developer" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Publisher" class="control-label">Publisher:</label>
<input asp-for="Game!.Publisher" class="form-control" />
<span asp-validation-for="Game!.Publisher" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Platform" class="control-label">Platform:</label>
<input asp-for="Game!.Platform" class="form-control" />
<span asp-validation-for="Game!.Platform" class="text-danger"></span>
</div>

<div class="form-group">
<label asp-for="Game!.Price" class="control-label">Price:</label>
<input asp-for="Game!.Price" class="form-control" type="number" step="0.01" />
<span asp-validation-for="Game!.Price" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Game!.Description" class="control-label">Description</label>
<label asp-for="Game!.Description" class="control-label">Description:</label>
<input asp-for="Game!.Description" class="form-control" />
<span asp-validation-for="Game!.Description" class="text-danger"></span>
</div>
Expand Down
84 changes: 42 additions & 42 deletions GameLibrary/Pages/Admin/Games/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@

@{
ViewData["Title"] = "Admin Page";
ViewData["ActivePage"] = ManageNavPages.Games;
ViewData["ActivePage"] = ManageNavPages.Games;
}

<body style="background-color: #000235; color: #FFD43B;">
<div class="container py-1">
<div class="row mb-4">
<div class="col-md-10">
<h1>Games</h1>
</div>
<div class="col-md-2 align-self-end">
<a asp-page="Create" class="btn" style="background-color: #420599; color: #FFD43B;">Create New</a>
</div>
<div class="container py-1">
<div class="row mb-4">
<div class="col-md-10">
<h1>Games</h1>
</div>
<div class="col-md-2 align-self-end">
<a asp-page="Create" class="btn" style="background-color: #420599; color: #FFD43B;">Create New</a>
</div>
</div>
</div>
<!--Table of all Games Section-->
<div class="container py-1">
<table class="table table-responsive" style="background-color: #000235;">
<thead>
<tr style=" color:#FFD43B;">
<th style="color:#FFD43B;">Game Details</th>
<th style="color:#FFD43B;">Image</th>
<th style="color:#FFD43B;">Actions</th>
</tr>
</thead>
<tbody style=" color:#FFD43B;">
@foreach (var item in Model.Games!)
{
<tr>
<td>
<strong style="color:#FFD43B;">Title:</strong> @Html.DisplayFor(modelItem => item.Title)<br />
<strong style="color:#FFD43B;">Genre:</strong> @Html.DisplayFor(modelItem => item.Genre)<br />
<strong style="color:#FFD43B;">Release Date:</strong> @item.ReleaseDate.ToString("MMMM dd, yyyy")<br />
<strong style="color:#FFD43B;">Description:</strong> @Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<img src="@item.ImageUrl" class="img-fluid rounded" title="Game Image" style="max-width:250px; min-width:100px; height: auto;" />
</td>
<td class="align-middle text-center">
<a asp-page="./Edit" asp-route-id="@item.Id" class="btn btn-primary btn-sm" style="background-color: #420599; color: #FFD43B;">Edit</a><br /><br />
<a asp-page="./Details" asp-route-id="@item.Id" class="btn btn-info btn-sm" style="background-color: #420599; color: #FFD43B;">Details</a><br /><br />
<a asp-page="./Delete" asp-route-id="@item.Id" class="btn btn-danger btn-sm" style="background-color: #420599; color: #FFD43B;">Delete</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<br />
<div class="container py-1">
<table class="table table-responsive" style="background-color: #000235;">
<thead>
<tr style=" color:#FFD43B;">
<th style="color:#FFD43B;">Game Details</th>
<th style="color:#FFD43B;">Image</th>
<th style="color:#FFD43B;">Actions</th>
</tr>
</thead>
<tbody style=" color:#FFD43B;">
@foreach (var item in Model.Games!)
{
<tr>
<td>
<strong style="color:#FFD43B;">Title:</strong> @Html.DisplayFor(modelItem => item.Title)<br />
<strong style="color:#FFD43B;">Genre:</strong> @Html.DisplayFor(modelItem => item.Genre)<br />
<strong style="color:#FFD43B;">Release Date:</strong> @item.ReleaseDate.ToString("MMMM dd, yyyy")<br />
<strong style="color:#FFD43B;">Description:</strong> @Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<img src="@item.ImageUrl" class="img-fluid rounded" title="Game Image" style="max-width:250px; min-width:100px; height: auto;" />
</td>
<td class="align-middle text-center">
<a asp-page="./Edit" asp-route-id="@item.Id" class="btn btn-primary btn-sm" style="background-color: #420599; color: #FFD43B;">Edit</a><br /><br />
<a asp-page="./Details" asp-route-id="@item.Id" class="btn btn-info btn-sm" style="background-color: #420599; color: #FFD43B;">Details</a><br /><br />
<a asp-page="./Delete" asp-route-id="@item.Id" class="btn btn-danger btn-sm" style="background-color: #420599; color: #FFD43B;">Delete</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<br />
</body>
2 changes: 1 addition & 1 deletion GameLibrary/Pages/Admin/Users/Create.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace GameLibrary.Pages.Admin.Users;

public class CreateModel(ApplicationDbContext context, UserManager<User> userManager, RoleManager<Role> roleManager) : PageModel
public class CreateModel(UserManager<User> userManager, RoleManager<Role> roleManager) : PageModel
{
public IActionResult OnGet()
{
Expand Down
2 changes: 1 addition & 1 deletion GameLibrary/Pages/Admin/Users/Delete.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace GameLibrary.Pages.Admin.Users;

public class DeleteModel(ApplicationDbContext context, UserManager<User> userManager) : PageModel
public class DeleteModel(UserManager<User> userManager) : PageModel
{
[BindProperty]
public User? IdentityUser { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion GameLibrary/Pages/Moderator/ManageNavPages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public static string PageNavClass(ViewContext viewContext, string page)
{
var activePage = viewContext.ViewData["ActivePage"] as string
?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null!;
}
}
Loading

0 comments on commit 0205353

Please sign in to comment.