Skip to content

Commit

Permalink
Topic catalogging - fix js error and enable the ability to uncatalog …
Browse files Browse the repository at this point in the history
…a topic
  • Loading branch information
adelikat committed Sep 7, 2024
1 parent 7134edb commit fecb04d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 6 additions & 5 deletions TASVideos/Pages/Forum/Topics/Catalog.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public class CatalogModel(ApplicationDbContext db) : BasePageModel
public string Title { get; set; } = "";

[BindProperty]
[Required]
public int? SystemId { get; set; }

[BindProperty]
[Required]
public int? GameId { get; set; }

public async Task<IActionResult> OnGet()
Expand Down Expand Up @@ -63,10 +61,13 @@ public async Task<IActionResult> OnPost()
return NotFound();
}

var gameExists = await db.Games.AnyAsync(g => g.Id == GameId);
if (!gameExists)
if (GameId.HasValue)
{
return BadRequest();
var gameExists = GameId.HasValue && await db.Games.AnyAsync(g => g.Id == GameId);
if (!gameExists)
{
return BadRequest();
}
}

topic.GameId = GameId;
Expand Down
6 changes: 4 additions & 2 deletions TASVideos/wwwroot/js/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ function enableCataloging() {
setSyncVerifiedCheckbox();
}

versionModel.onchange = function() {
setSyncVerifiedCheckbox();
if (versionModel) {
versionModel.onchange = function() {
setSyncVerifiedCheckbox();
}
}

document.getElementById('create-version')?.addEventListener('click', function () {
Expand Down

0 comments on commit fecb04d

Please sign in to comment.