Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Model #19

Merged
merged 16 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ jobs:

runs-on: ubuntu-latest

env:
CI: true

steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Azure Functions Core Tools
run: npm install -g azure-functions-core-tools@3 --unsafe-perm true
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -45,7 +54,7 @@ jobs:
dotnet build --no-restore ./MPM-Betting.IntegrationTests/MPM-Betting.IntegrationTests.csproj
dotnet build --no-restore ./MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/MPM-Betting.Aspire.AppHost.csproj
dotnet build --no-restore ./MPM-Betting.Aspire/MPM-Betting.Aspire.ServiceDefaults/MPM-Betting.Aspire.ServiceDefaults.csproj
- name: Test
run: |
dotnet test --no-build --verbosity normal ./MPM-Betting.UnitTests/MPM-Betting.UnitTests.csproj
dotnet test --no-build --verbosity normal ./MPM-Betting.IntegrationTests/MPM-Betting.IntegrationTests.csproj
- name: Unit Test
run: dotnet test --no-build --verbosity normal ./MPM-Betting.UnitTests/MPM-Betting.UnitTests.csproj
- name: Integration Test
run: dotnet test --no-build --verbosity normal ./MPM-Betting.IntegrationTests/MPM-Betting.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static IResourceBuilder<ExecutableResource> AddAzureFunction<TServiceMeta
};

return builder.AddExecutable(name, "func", projectDirectory, args)
.WithHttpEndpoint(7122, 7122, isProxied: false)
.WithOtlpExporter();
}

Expand Down
20 changes: 12 additions & 8 deletions MPM-Betting.Aspire/MPM-Betting.Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
var grafana = builder.AddContainer("grafana", "grafana/grafana")
.WithBindMount(GetFullPath("../grafana/config"), "/etc/grafana", isReadOnly: false)
.WithBindMount(GetFullPath("../grafana/dashboards"), "/var/lib/grafana/dashboards", isReadOnly: false)
.WithEndpoint(port: 3000, targetPort: 3000, name: "grafana-http", scheme: "http");
.WithHttpEndpoint(port: 3000, targetPort: 3000);

var prometheus = builder.AddContainer("prometheus", "prom/prometheus")
.WithBindMount(GetFullPath("../prometheus"), "/etc/prometheus")
.WithEndpoint(port: 9090, targetPort: 9090, name: "prometheus-http", scheme: "http");
.WithHttpEndpoint(port: 9090, targetPort: 9090);

var redis = builder.AddRedis("redis")
.WithPersistence()
Expand All @@ -39,30 +39,34 @@
.PublishAsAzureSqlDatabase()
.AddDatabase("MPM-Betting");

if (builder.ExecutionContext.IsPublishMode)

var mail = builder.AddMailDev("maildev", 9324, 9325);

if (builder.ExecutionContext.IsPublishMode || Environment.GetEnvironmentVariable("CI") == "true")
{
var api = builder.AddProject<MPM_Betting_Api>("api")
.WithExternalHttpEndpoints()
.WithReference(sql)
.WithReference(redis);
.WithReference(redis)
.WithReference(mail);

var blazor = builder.AddProject<MPM_Betting_Blazor>("blazor")
.WithExternalHttpEndpoints()
.WithReference(api)
.WithReference(redis)
.WithReference(sql);
.WithReference(sql)
.WithReference(mail);
}
else
{
var mailDev = builder.AddMailDev("maildev", 9324, 9325);

var api = builder.AddProjectWithDotnetWatch<MPM_Betting_Api>("api")
.WithHttpEndpoint(targetPort: 5241, port: 5241, isProxied: false)
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
.WithEnvironment("DOTNET_ENVIRONMENT", "Development")
.WithReference(sql)
.WithReference(redis)
.WithReference(mailDev);
.WithReference(mail);

var blazor = builder.AddProjectWithDotnetWatch<MPM_Betting_Blazor>("blazor")
.WithHttpEndpoint(targetPort: 5023, port: 5023, isProxied: false)
Expand All @@ -71,7 +75,7 @@
.WithEnvironment("DOTNET_ENVIRONMENT", "Development")
.WithReference(redis)
.WithReference(sql)
.WithReference(mailDev);
.WithReference(mail);
}

var dbManager = builder.AddProject<MPM_Betting_DbManager>("dbmanager")
Expand Down
23 changes: 23 additions & 0 deletions MPM-Betting.DataModel/Betting/Bet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
using MPM_Betting.DataModel.User;

namespace MPM_Betting.DataModel.Betting;

public class Bet(MpmUser user, MpmGroup? group, Game game, EBetType type)
{
[Key]
public int Id { get; set; }

public MpmUser User { get; set; } = user;
public MpmGroup? Group { get; set; } = group;

public bool Completed { get; set; }

public int Score { get; set; }

public Game Game { get; set; } = game;

public EBetType Type { get; set; } = type;

private Bet() : this(null!, null!, null!, EBetType.None) {}
}
10 changes: 10 additions & 0 deletions MPM-Betting.DataModel/Betting/BuiltinSeason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;

namespace MPM_Betting.DataModel.Betting;

public class BuiltinSeason(string name, string description) : Season(name, description)
{
public List<Game> Games = [];

private BuiltinSeason() : this(null!, null!) {}
}
8 changes: 8 additions & 0 deletions MPM-Betting.DataModel/Betting/CustomSeason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.ComponentModel.DataAnnotations;

namespace MPM_Betting.DataModel.Betting;

public class CustomSeason(string name, string description) : Season(name, description)
{
private CustomSeason() : this(null!, null!) {}
}
15 changes: 15 additions & 0 deletions MPM-Betting.DataModel/Betting/CustomSeasonEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;

namespace MPM_Betting.DataModel.Betting;

public class CustomSeasonEntry(CustomSeason season, Game game)
{
[Key]
public int Id { get; set; }

public CustomSeason Season { get; set; } = season;

public Game Game { get; set; } = game;

private CustomSeasonEntry() : this(null!, null!) { }
}
8 changes: 8 additions & 0 deletions MPM-Betting.DataModel/Betting/EBetType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MPM_Betting.DataModel.Betting;

public enum EBetType
{
None = 0,
FootballResult,
FootballScore,
}
7 changes: 7 additions & 0 deletions MPM-Betting.DataModel/Betting/ESportType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace MPM_Betting.DataModel.Betting;

public enum ESportType
{
None = 0,
Football
}
21 changes: 21 additions & 0 deletions MPM-Betting.DataModel/Betting/Game.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;

namespace MPM_Betting.DataModel.Betting;

public class Game(string name, BuiltinSeason season)

Check warning on line 5 in MPM-Betting.DataModel/Betting/Game.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Non-nullable property 'Bets' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 5 in MPM-Betting.DataModel/Betting/Game.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Non-nullable property 'Bets' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
[Key]
public int Id { get; set; }

public string Name { get; set; } = name;

public ESportType SportType { get; set; }

public List<Bet> Bets { get; set; }

public BuiltinSeason? BuiltinSeason { get; set; } = season;

public int ReferenceId { get; set; }

private Game() : this(null!, null!) {}
}
18 changes: 18 additions & 0 deletions MPM-Betting.DataModel/Betting/ScoreEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using MPM_Betting.DataModel.User;

namespace MPM_Betting.DataModel.Betting;

public class ScoreEntry(UserGroupEntry userGroupEntry, SeasonEntry seasonEntry)
{
[Key]
public int Id { get; set; }

public UserGroupEntry UserGroupEntry { get; set; } = userGroupEntry;

public SeasonEntry SeasonEntry { get; set; } = seasonEntry;

public int Score { get; set; } = 0;

private ScoreEntry() : this(null!, null!) {}
}
22 changes: 22 additions & 0 deletions MPM-Betting.DataModel/Betting/Season.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;

namespace MPM_Betting.DataModel.Betting;

public class Season(string name, string description)
{
[Key]
public int Id { get; set; }

[StringLength(50)]
public string Name { get; set; } = name;

[StringLength(2000)]
public string Description { get; set; } = description;

public ESportType Sport { get; set; }

public DateTime Start { get; set; }
public DateTime End { get; set; }

public int ReferenceId { get; set; }
}
20 changes: 20 additions & 0 deletions MPM-Betting.DataModel/Betting/SeasonEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
using MPM_Betting.DataModel.User;

namespace MPM_Betting.DataModel.Betting;

public class SeasonEntry(string name, MpmGroup group, Season season)

Check warning on line 6 in MPM-Betting.DataModel/Betting/SeasonEntry.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Parameter 'name' is unread.

Check warning on line 6 in MPM-Betting.DataModel/Betting/SeasonEntry.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Parameter 'name' is unread.
{
[Key]
public int Id { get; set; }

public MpmGroup Group { get; set; } = group;

public Season Season { get; set; } = season;

public bool IsActive { get; set; } = true;

public List<ScoreEntry> ScoreEntries { get; set; } = [];

private SeasonEntry() : this(null!, null!, null!) { }
}
54 changes: 0 additions & 54 deletions MPM-Betting.DataModel/Country.cs

This file was deleted.

6 changes: 6 additions & 0 deletions MPM-Betting.DataModel/Football/EPlayerBodyParts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace MPM_Betting.DataModel.Football;

public enum EPlayerBodyParts
{
LeftFoot, RightFoot, Head
}
10 changes: 10 additions & 0 deletions MPM-Betting.DataModel/Football/EResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MPM_Betting.DataModel.Football;

public enum EResult
{
None = 0,
Win, // Home Team wind
Draw,
Loss, // Away team wins
Canceled
}
10 changes: 10 additions & 0 deletions MPM-Betting.DataModel/Football/ERound.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MPM_Betting.DataModel.Betting;

public enum ERound
{
Last32,
Last16,
Quarterfinal,
Semifinal,
Final
}
6 changes: 6 additions & 0 deletions MPM-Betting.DataModel/Football/ESide.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace MPM_Betting.DataModel.Football;

public enum ESide
{
LeftTop, LeftBottom, RightTop, RightBottom
}
11 changes: 11 additions & 0 deletions MPM-Betting.DataModel/Football/ResultBet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MPM_Betting.DataModel.Betting;
using MPM_Betting.DataModel.User;

namespace MPM_Betting.DataModel.Football;

public class ResultBet(MpmUser user, MpmGroup? group, Game game, EResult result) : Bet(user, group, game, EBetType.FootballResult)
{
public EResult Result { get; set; } = result;

private ResultBet() : this(null!, null!, null!, EResult.None) {}
}
12 changes: 12 additions & 0 deletions MPM-Betting.DataModel/Football/ScoreBet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MPM_Betting.DataModel.Betting;
using MPM_Betting.DataModel.User;

namespace MPM_Betting.DataModel.Football;

public class ScoreBet(MpmUser user, MpmGroup? group, Game game, int homeScore, int awayScore) : Bet(user, group, game, EBetType.FootballResult)
{
public int HomeScore { get; set; } = homeScore;
public int AwayScore { get; set; } = awayScore;

private ScoreBet() : this(null!, null!, null!, 0, 0) {}
}
Loading
Loading