diff --git a/ServerCore/Pages/Events/Index.cshtml b/ServerCore/Pages/Events/Index.cshtml
index ab825f0c..98e54545 100644
--- a/ServerCore/Pages/Events/Index.cshtml
+++ b/ServerCore/Pages/Events/Index.cshtml
@@ -13,63 +13,15 @@
-
- @Html.DisplayNameFor(model => model.Event[0].Name)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].UrlString)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].MaxNumberOfTeams)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].MaxTeamSize)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].MaxExternalsPerTeam)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].IsInternEvent)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamRegistrationBegin)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamRegistrationEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamNameChangeEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamMembershipChangeEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamMiscDataChangeEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].TeamDeleteEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].EventBegin)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].AnswerSubmissionEnd)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].AnswersAvailableBegin)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].StandingsAvailableBegin)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].StandingsOverride)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].ShowFastestSolves)
- |
-
- @Html.DisplayNameFor(model => model.Event[0].AllowFeedback)
- |
+
+ @Html.DisplayNameFor(model => model.Event[0].Name)
+ |
+
+ @Html.DisplayNameFor(model => model.Event[0].UrlString)
+ |
+
+ @Html.DisplayNameFor(model => model.Event[0].IsInternEvent)
+ |
|
@@ -82,61 +34,14 @@
@Html.DisplayFor(modelItem => item.UrlString)
|
-
- @Html.DisplayFor(modelItem => item.MaxNumberOfTeams)
- |
-
- @Html.DisplayFor(modelItem => item.MaxTeamSize)
- |
-
- @Html.DisplayFor(modelItem => item.MaxExternalsPerTeam)
- |
@Html.DisplayFor(modelItem => item.IsInternEvent)
|
-
- @Html.DisplayFor(modelItem => item.TeamRegistrationBegin)
- |
-
- @Html.DisplayFor(modelItem => item.TeamRegistrationEnd)
- |
-
- @Html.DisplayFor(modelItem => item.TeamNameChangeEnd)
- |
-
- @Html.DisplayFor(modelItem => item.TeamMembershipChangeEnd)
- |
-
- @Html.DisplayFor(modelItem => item.TeamMiscDataChangeEnd)
- |
-
- @Html.DisplayFor(modelItem => item.TeamDeleteEnd)
- |
-
- @Html.DisplayFor(modelItem => item.EventBegin)
- |
-
- @Html.DisplayFor(modelItem => item.AnswerSubmissionEnd)
- |
-
- @Html.DisplayFor(modelItem => item.AnswersAvailableBegin)
- |
-
- @Html.DisplayFor(modelItem => item.StandingsAvailableBegin)
- |
-
- @Html.DisplayFor(modelItem => item.StandingsOverride)
- |
-
- @Html.DisplayFor(modelItem => item.ShowFastestSolves)
- |
-
- @Html.DisplayFor(modelItem => item.AllowFeedback)
- |
Edit |
Details |
- Delete
+ Delete |
+ Puzzles
|
}
diff --git a/ServerCore/Pages/Index.cshtml b/ServerCore/Pages/Index.cshtml
index f0a923a4..15f43297 100644
--- a/ServerCore/Pages/Index.cshtml
+++ b/ServerCore/Pages/Index.cshtml
@@ -71,7 +71,7 @@
Guide to Microsoft Puzzle Events
- - CLICK HERE TO CHECK YOUR DATABASE SETUP
+ - CLICK HERE TO CHECK YOUR DATABASE SETUP
- Intern? Click Here
- Non-Intern Beginner? Click Here
- Advanced Solver? Click Here
diff --git a/ServerCore/Pages/Puzzles/Create.cshtml.cs b/ServerCore/Pages/Puzzles/Create.cshtml.cs
index 54c05de7..bd913293 100644
--- a/ServerCore/Pages/Puzzles/Create.cshtml.cs
+++ b/ServerCore/Pages/Puzzles/Create.cshtml.cs
@@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.EntityFrameworkCore;
using ServerCore.DataModel;
using ServerCore.Models;
@@ -27,17 +28,19 @@ public IActionResult OnGet()
[BindProperty]
public Puzzle Puzzle { get; set; }
- public async Task OnPostAsync()
+ public async Task OnPostAsync(int eventid)
{
if (!ModelState.IsValid)
{
return Page();
}
+ Puzzle.Event = await _context.Event.SingleOrDefaultAsync(m => m.ID == eventid);
+
_context.Puzzle.Add(Puzzle);
await _context.SaveChangesAsync();
- return RedirectToPage("./Index");
+ return RedirectToPage("./Index", new { eventid = eventid });
}
}
}
\ No newline at end of file
diff --git a/ServerCore/Pages/Puzzles/Delete.cshtml b/ServerCore/Pages/Puzzles/Delete.cshtml
index 71941a0b..6daa03f9 100644
--- a/ServerCore/Pages/Puzzles/Delete.cshtml
+++ b/ServerCore/Pages/Puzzles/Delete.cshtml
@@ -95,6 +95,6 @@
diff --git a/ServerCore/Pages/Puzzles/Delete.cshtml.cs b/ServerCore/Pages/Puzzles/Delete.cshtml.cs
index b7e2867f..945efda2 100644
--- a/ServerCore/Pages/Puzzles/Delete.cshtml.cs
+++ b/ServerCore/Pages/Puzzles/Delete.cshtml.cs
@@ -29,7 +29,7 @@ public async Task OnGetAsync(int? id)
return NotFound();
}
- Puzzle = await _context.Puzzle.SingleOrDefaultAsync(m => m.ID == id);
+ Puzzle = await _context.Puzzle.Where(m => m.ID == id).Include(p => p.Event).FirstOrDefaultAsync();
if (Puzzle == null)
{
@@ -45,7 +45,7 @@ public async Task OnPostAsync(int? id)
return NotFound();
}
- Puzzle = await _context.Puzzle.FindAsync(id);
+ Puzzle = await _context.Puzzle.Where(m => m.ID == id).Include(p => p.Event).FirstOrDefaultAsync();
if (Puzzle != null)
{
@@ -53,7 +53,7 @@ public async Task OnPostAsync(int? id)
await _context.SaveChangesAsync();
}
- return RedirectToPage("./Index");
+ return RedirectToPage("./Index", new { eventid = Puzzle.Event?.ID });
}
}
}
diff --git a/ServerCore/Pages/Puzzles/Details.cshtml b/ServerCore/Pages/Puzzles/Details.cshtml
index b8912587..185965bb 100644
--- a/ServerCore/Pages/Puzzles/Details.cshtml
+++ b/ServerCore/Pages/Puzzles/Details.cshtml
@@ -93,5 +93,5 @@
diff --git a/ServerCore/Pages/Puzzles/Details.cshtml.cs b/ServerCore/Pages/Puzzles/Details.cshtml.cs
index 17a66c58..4719cd30 100644
--- a/ServerCore/Pages/Puzzles/Details.cshtml.cs
+++ b/ServerCore/Pages/Puzzles/Details.cshtml.cs
@@ -28,7 +28,7 @@ public async Task OnGetAsync(int? id)
return NotFound();
}
- Puzzle = await _context.Puzzle.SingleOrDefaultAsync(m => m.ID == id);
+ Puzzle = await _context.Puzzle.Where(m => m.ID == id).Include(p => p.Event).FirstOrDefaultAsync();
if (Puzzle == null)
{
diff --git a/ServerCore/Pages/Puzzles/Edit.cshtml b/ServerCore/Pages/Puzzles/Edit.cshtml
index 6aa50984..bc4ee83e 100644
--- a/ServerCore/Pages/Puzzles/Edit.cshtml
+++ b/ServerCore/Pages/Puzzles/Edit.cshtml
@@ -95,7 +95,7 @@
@section Scripts {
diff --git a/ServerCore/Pages/Puzzles/Edit.cshtml.cs b/ServerCore/Pages/Puzzles/Edit.cshtml.cs
index 03eac2c2..6a532efd 100644
--- a/ServerCore/Pages/Puzzles/Edit.cshtml.cs
+++ b/ServerCore/Pages/Puzzles/Edit.cshtml.cs
@@ -30,7 +30,7 @@ public async Task OnGetAsync(int? id)
return NotFound();
}
- Puzzle = await _context.Puzzle.SingleOrDefaultAsync(m => m.ID == id);
+ Puzzle = await _context.Puzzle.Where(m => m.ID == id).Include(p => p.Event).FirstOrDefaultAsync();
if (Puzzle == null)
{
@@ -64,7 +64,7 @@ public async Task OnPostAsync()
}
}
- return RedirectToPage("./Index");
+ return RedirectToPage("./Index", new { eventid = Puzzle.Event?.ID });
}
private bool PuzzleExists(int id)
diff --git a/ServerCore/Pages/Puzzles/Index.cshtml b/ServerCore/Pages/Puzzles/Index.cshtml
index e6f1f995..56546e88 100644
--- a/ServerCore/Pages/Puzzles/Index.cshtml
+++ b/ServerCore/Pages/Puzzles/Index.cshtml
@@ -8,7 +8,7 @@
Index
- Create New
+ Create New
diff --git a/ServerCore/Pages/Puzzles/Index.cshtml.cs b/ServerCore/Pages/Puzzles/Index.cshtml.cs
index aaec7078..b33cc988 100644
--- a/ServerCore/Pages/Puzzles/Index.cshtml.cs
+++ b/ServerCore/Pages/Puzzles/Index.cshtml.cs
@@ -19,11 +19,21 @@ public IndexModel(ServerCore.Models.PuzzleServerContext context)
_context = context;
}
- public IList Puzzle { get;set; }
+ public IList Puzzle { get; set; }
- public async Task OnGetAsync()
+ public int? EventId { get; set; }
+
+ public async Task OnGetAsync(int? eventid)
{
- Puzzle = await _context.Puzzle.ToListAsync();
+ if (eventid != null)
+ {
+ Puzzle = await _context.Puzzle.Where((p) => p.Event != null && p.Event.ID == eventid).ToListAsync();
+ EventId = eventid;
+ }
+ else
+ {
+ Puzzle = await _context.Puzzle.ToListAsync();
+ }
}
}
}