matches)
23 | {
24 | return matchBets.Select(x => {
25 | var match = matches.First(m => m.Number == x.MatchId);
26 | return x.ToPlayerMatchBetDto(match);
27 |
28 | } );
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Frontend/Euro2024Challange/Components/Pages/Error.razor:
--------------------------------------------------------------------------------
1 | @page "/Error"
2 | @using System.Diagnostics
3 |
4 | Error
5 |
6 | Error.
7 | An error occurred while processing your request.
8 |
9 | @if (ShowRequestId)
10 | {
11 |
12 | Request ID: @RequestId
13 |
14 | }
15 |
16 | Development Mode
17 |
18 | Swapping to Development environment will display more detailed information about the error that occurred.
19 |
20 |
21 | The Development environment shouldn't be enabled for deployed applications.
22 | It can result in displaying sensitive information from exceptions to end users.
23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
24 | and restarting the app.
25 |
26 |
27 | @code{
28 | [CascadingParameter]
29 | private HttpContext? HttpContext { get; set; }
30 |
31 | private string? RequestId { get; set; }
32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
33 |
34 | protected override void OnInitialized() =>
35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
36 | }
37 |
--------------------------------------------------------------------------------
/src/Backend/Modules/Classification/Euro2024Challenge.Backend.Modules.Classification.Application/Classifications/CreatePlayerClassification/CreatePlayerClassificationCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using Euro2024Challenge.Backend.Modules.Classification.Domain.Entities;
2 | using Euro2024Challenge.Backend.Modules.Classification.Domain.Repositories;
3 | using MediatR;
4 |
5 | namespace Euro2024Challenge.Backend.Modules.Classification.Application.Classifications.CreatePlayerClassification;
6 |
7 | public class CreatePlayerClassificationCommandHandler : IRequestHandler
8 | {
9 | readonly IClassificationRepository _classificationRepository;
10 | public CreatePlayerClassificationCommandHandler(IClassificationRepository classificationRepository)
11 | {
12 | _classificationRepository = classificationRepository;
13 | }
14 |
15 | public async Task Handle(CreatePlayerClassificationCommand request, CancellationToken cancellationToken)
16 | {
17 | PlayerBetPoints playerBetPoints = new()
18 | {
19 | Id = Guid.NewGuid().ToString(),
20 | PlayerId = request.PlayerId.ToString(),
21 | BetId = request.BetId.ToString(),
22 | Points = request.Points
23 | };
24 |
25 | await _classificationRepository.Insert(playerBetPoints);
26 |
27 | return Unit.Value;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Backend/Modules/Players/Euro2024Challenge.Backend.Modules.Players.Application/Bets/Update/UpdateMatchBetCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using Euro2024Challenge.Backend.Modules.Players.Domain.Entities;
2 | using Euro2024Challenge.Backend.Modules.Players.Domain.Repositories;
3 | using Euro2024Challenge.Backend.Modules.Players.Domain.ValueObjects;
4 | using MediatR;
5 |
6 | namespace Euro2024Challenge.Backend.Modules.Players.Application.Bets.Update
7 | {
8 | public class UpdateMatchBetCommandHandler : IRequestHandler
9 | {
10 | private readonly IPlayersBetsRepository _playersBetsRepository;
11 |
12 | public UpdateMatchBetCommandHandler(IPlayersBetsRepository playersBetsRepository)
13 | {
14 | _playersBetsRepository = playersBetsRepository;
15 | }
16 |
17 | public async Task Handle(UpdateMatchBetCommand request, CancellationToken cancellationToken)
18 | {
19 | var bet = new MatchBet
20 | {
21 | MatchId = request.MatchId,
22 | Result = MatchResult.CreateNew((ushort)request.HomeTeamGoals, (ushort)request.AwayTeamGoals),
23 | PlayerId = request.PLayerId,
24 | Winner = request.Winner
25 | };
26 |
27 | await _playersBetsRepository.UpdateMatchBetAsync(bet);
28 |
29 | return Unit.Value;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Backend/Modules/Players/Euro2024Challenge.Backend.Modules.Players.Application/Bets/Create/CreateMatchBetCommandHandler.cs:
--------------------------------------------------------------------------------
1 | using Euro2024Challenge.Backend.Modules.Players.Domain.Entities;
2 | using Euro2024Challenge.Backend.Modules.Players.Domain.Repositories;
3 | using Euro2024Challenge.Backend.Modules.Players.Domain.ValueObjects;
4 | using MediatR;
5 |
6 | namespace Euro2024Challenge.Backend.Modules.Players.Application.Bets.Create
7 | {
8 | public class CreateMatchBetCommandHandler : IRequestHandler
9 | {
10 | private readonly IPlayersBetsRepository _playersBetsRepository;
11 |
12 | public CreateMatchBetCommandHandler(IPlayersBetsRepository playersBetsRepository)
13 | {
14 | _playersBetsRepository = playersBetsRepository;
15 | }
16 |
17 | public async Task Handle(CreateMatchBetCommand request, CancellationToken cancellationToken)
18 | {
19 | var bet = new MatchBet
20 | {
21 | MatchId = request.MatchId,
22 | Result = MatchResult.CreateNew((ushort)request.HomeTeamGoals, (ushort)request.AwayTeamGoals),
23 | PlayerId = request.PLayerId,
24 | Winner = request.Winner
25 | };
26 |
27 | await _playersBetsRepository.CreateMatchBetAsync(bet);
28 |
29 | return Unit.Value;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Backend/Modules/Players/Euro2024Challenge.Backend.Modules.Players.Infrastructure/Euro2024Challenge.Backend.Modules.Players.Infrastructure.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | all
13 | runtime; build; native; contentfiles; analyzers; buildtransitive
14 |
15 |
16 |
17 | all
18 | runtime; build; native; contentfiles; analyzers; buildtransitive
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/Backend/Shared/Euro2024Challenge.Shared/Domain/ValueObject.cs:
--------------------------------------------------------------------------------
1 | namespace Euro2024Challenge.Shared.Domain;
2 |
3 | public abstract class ValueObject
4 | {
5 | protected static bool EqualOperator(ValueObject left, ValueObject right)
6 | {
7 | if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
8 | {
9 | return false;
10 | }
11 | return ReferenceEquals(left, right) || left.Equals(right);
12 | }
13 |
14 | protected static bool NotEqualOperator(ValueObject left, ValueObject right)
15 | {
16 | return !EqualOperator(left, right);
17 | }
18 |
19 | protected abstract IEnumerable