Skip to content

Issue#18 record games created#57

Merged
SuperGamer001 merged 10 commits intomasterfrom
Issue#18-RecordGamesCreated
Dec 3, 2025
Merged

Issue#18 record games created#57
SuperGamer001 merged 10 commits intomasterfrom
Issue#18-RecordGamesCreated

Conversation

@logprogrammer92
Copy link
Contributor

Closes #18

This pull request implements ownership tracking for games, enforces that only authenticated users can create games, and introduces a new GameListViewModel for improved listing and pagination. It also cleans up obsolete migrations and updates some NuGet package versions. The most important changes are grouped below:

Game Ownership and Authorization:

  • Added an OwnerId field to the GameModel entity, established a foreign key relationship to ApplicationUser, and updated the controller logic to set the owner to the currently logged-in user when creating a game. Only authenticated users can access the create action, and overposting of OwnerId is prevented. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Removed obsolete or incorrect migrations related to user following and the previous owner implementation, and replaced them with a new migration that properly sets up the owner foreign key. [1] [2] [3] [4] [5]

Game List View Model:

  • Introduced a new GameListViewModel class to support paginated and searchable game listings, paving the way for future UI improvements. [1] [2]

UI and Usability Improvements:

  • Updated the Create.cshtml view to remove the hidden rating input, simplifying the form for game creation.
  • Improved the Index.cshtml view for games by updating the title from "Index" to "Games" for better clarity.

Package Management:

  • Downgraded the Microsoft.AspNetCore.Identity.UI NuGet package from version 9.0.10 to 9.0.3 to address compatibility or dependency issues.

Miscellaneous:

  • Minor fixes to model snapshot and data annotations for consistency and correctness. [1] [2]

Introduce GameModel entity with Creator relationship to track
game creators. Add GamesController for CRUD operations and
corresponding Razor views (Create, Edit, Delete, Details, Index).
Include database migrations for schema updates, adding CreatorId
to GameModels and establishing foreign key constraints. Add
GameListViewModel for paginated game listings. Downgrade target
framework to .NET 9.0 and adjust package versions.
Introduce GameModel entity with Creator relationship to track
game creators. Add GamesController for CRUD operations and
corresponding Razor views (Create, Edit, Delete, Details, Index).
Include database migrations for schema updates, adding CreatorId
to GameModels and establishing foreign key constraints. Add
GameListViewModel for paginated game listings. Downgrade target
framework to .NET 9.0 and adjust package versions.
The closing curly brace (`}`) at the end of the `GameListViewModel` class in `GameModel.cs` was removed. This change ensures the class is properly closed to prevent syntax errors.
Updated the `GameModels` table to include a nullable `OwnerId`
column, replacing the required `CreatorId` and `Creator`
properties. Modified the `Rating` property to allow null
values (`int?`) for greater flexibility. Adjusted the
`ApplicationDbContextModelSnapshot` and `GameModel` class
to reflect these changes.
The `GamesController.cs` file has been entirely removed, including all CRUD actions for managing `GameModel` entities, dependency injection, and helper methods like `GameModelExists`.

All associated Razor views (`Index.cshtml`, `Create.cshtml`, `Edit.cshtml`, `Delete.cshtml`, `Details.cshtml`) have also been removed. These views previously handled the UI for managing `GameModel` entities.

The `Index.cshtml` file was modified to update the page title from "Index" to "Games" in the `ViewData["Title"]` and `<h1>` tags. This change may indicate a partial or ongoing refactor.
Enhanced `GameModelsController` to support user authentication:
- Added `UserManager<ApplicationUser>` dependency.
- Applied `[Authorize]` to `Create` actions.
- Ensured `Create` POST action sets `OwnerId` to the logged-in user.

Simplified `Create.cshtml` by removing the `Rating` field and its UI elements.
@logprogrammer92 logprogrammer92 self-assigned this Dec 1, 2025
@logprogrammer92 logprogrammer92 added enhancement New feature or request front end Issue for front end development. (Client-side, web pages) back end Issue for back end development. (Server-side) labels Dec 1, 2025
Copy link
Member

@SuperGamer001 SuperGamer001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible I'm having migration issues again. :(

I'm getting an error on line 29 in the GameModelController that I have an invalid column name named "OwnerId"

@SuperGamer001 SuperGamer001 self-requested a review December 3, 2025 22:20
@SuperGamer001 SuperGamer001 merged commit e9b76cd into master Dec 3, 2025
1 check passed
@SuperGamer001 SuperGamer001 deleted the Issue#18-RecordGamesCreated branch December 5, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

back end Issue for back end development. (Server-side) enhancement New feature or request front end Issue for front end development. (Client-side, web pages)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to record Games Created

2 participants