43 lines
1002 B
C#
43 lines
1002 B
C#
|
|
using Giants.Core.Interfaces;
|
|
|
|
namespace Giants.Core.Commands;
|
|
|
|
/// <summary>
|
|
/// Logique metier qui permet d'ajouter les données statiques aux matchs qui arrivent du repository
|
|
/// </summary>
|
|
public class GetMatchCommand : BaseCommand<GetMatchResult>
|
|
{
|
|
private IMatchRepository _repo;
|
|
|
|
/// <summary> L'id du match a récupérer </summary>
|
|
public required int MatchId { get; init; }
|
|
|
|
public GetMatchCommand(IMatchRepository repo)
|
|
{
|
|
_repo = repo;
|
|
}
|
|
|
|
protected override GetMatchResult LocalExecute()
|
|
{
|
|
Match? m = _repo.GetMatch(MatchId);
|
|
if (null != m)
|
|
{
|
|
|
|
GetMatchResult result = new GetMatchResult()
|
|
{
|
|
Success = true,
|
|
Match = m
|
|
};
|
|
return result;
|
|
}
|
|
|
|
return new GetMatchResult() { };
|
|
}
|
|
}
|
|
|
|
public class GetMatchResult : BaseCommandResult
|
|
{
|
|
/// <summary> Le match si success null sinon </summary>
|
|
public Match? Match { get; init; }
|
|
} |