Skip to content

Commit

Permalink
[wip] Routing (#10)
Browse files Browse the repository at this point in the history
Routing and css foo
Co-authored-by: M-Munier <marc@geomaps.de>
  • Loading branch information
Trolldemorted authored Apr 30, 2020
1 parent d6bf472 commit e7320fd
Show file tree
Hide file tree
Showing 23 changed files with 916 additions and 249 deletions.
2 changes: 1 addition & 1 deletion ChallengePad.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChallengePad", "ChallengePad\ChallengePad.csproj", "{BB613FE4-3052-49C8-915A-FB00A38749FD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChallengePad", "ChallengePad\ChallengePad.csproj", "{BB613FE4-3052-49C8-915A-FB00A38749FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 5 additions & 1 deletion ChallengePad/App.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<ChallengePad.Pages.LoginView />
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
Expand Down
2 changes: 1 addition & 1 deletion ChallengePad/ChallengePad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
<PackageReference Include="ServiceStack.Redis" Version="5.7.0" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
Expand Down
2 changes: 1 addition & 1 deletion ChallengePad/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AccountController : Controller
[HttpGet]
public IActionResult Get()
{
return Challenge(new AuthenticationProperties() { RedirectUri = "/" });
return Challenge(new AuthenticationProperties() { RedirectUri = "/", }, new string[] { "OAuth" });
}
}
}
11 changes: 11 additions & 0 deletions ChallengePad/Database/ChallengePadDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ public async Task<Operation> GetOperation(long id, CancellationToken token)
.SingleAsync(token);
}

public async Task<Operation> GetOperation(string name, CancellationToken token)
{
Logger.LogDebug($"GetOperation({name})");
return await Context.Operations
.Where(op => op.Name == name)
.Include(op => op.Files)
.Include(op => op.Objectives)
.ThenInclude(obj => obj.Files)
.SingleAsync(token);
}

public async Task CreateObjective(string name, string category, long points, long operationId, CancellationToken token)
{
Logger.LogDebug($"CreateObjective({name}, {category}, {points}, {operationId})");
Expand Down
6 changes: 6 additions & 0 deletions ChallengePad/Database/ChallengePadDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Operation>()
.Ignore(b => b.Categories);

modelBuilder.Entity<Operation>()
.HasIndex(p => p.Name).IsUnique();

modelBuilder.Entity<Objective>()
.HasIndex(p => new { p.OperationId, p.Name }).IsUnique();
}
}
}
1 change: 1 addition & 0 deletions ChallengePad/Database/IChallengePadDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface IChallengePadDb
Task<Operation[]> GetOperations(int skip, int take, CancellationToken token);
Task CreateOperation(string name, CancellationToken token);
Task<Operation> GetOperation(long id, CancellationToken token);
Task<Operation> GetOperation(string name, CancellationToken token);
Task CreateObjective(string name, string category, long points, long operationId, CancellationToken token);
Task UpdateObjective(long objectiveId, long operationId, bool solved, CancellationToken token);
Task UpdateObjectiveVisiblity(long objectiveId, long operationId, bool visible, CancellationToken token);
Expand Down
133 changes: 133 additions & 0 deletions ChallengePad/Migrations/20200429221600_m3.Designer.cs

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

32 changes: 32 additions & 0 deletions ChallengePad/Migrations/20200429221600_m3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace ChallengePad.Migrations
{
public partial class m3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Objectives_OperationId",
table: "Objectives");

migrationBuilder.CreateIndex(
name: "IX_Objectives_OperationId_Name",
table: "Objectives",
columns: new[] { "OperationId", "Name" },
unique: true);
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Objectives_OperationId_Name",
table: "Objectives");

migrationBuilder.CreateIndex(
name: "IX_Objectives_OperationId",
table: "Objectives",
column: "OperationId");
}
}
}
136 changes: 136 additions & 0 deletions ChallengePad/Migrations/20200430122632_m4.Designer.cs

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

Loading

0 comments on commit e7320fd

Please sign in to comment.