38 lines
857 B
C#
38 lines
857 B
C#
using Giants.Core.Interfaces;
|
|
|
|
namespace Giants.Core.Commands;
|
|
|
|
/// <summary>
|
|
/// Commande permettant de créer un nouveau match
|
|
/// </summary>
|
|
public class NewMatchCommand : BaseCommand<NewMatchResult>
|
|
{
|
|
private readonly IMatchRepository _repo;
|
|
|
|
/// <summary>
|
|
/// constructeur
|
|
/// </summary>
|
|
/// <param name="repo">le repository de match</param>
|
|
public NewMatchCommand(IMatchRepository repo)
|
|
{
|
|
_repo = repo;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
protected override sealed NewMatchResult LocalExecute()
|
|
{
|
|
var match = _repo.CreateMatch();
|
|
|
|
return new NewMatchResult()
|
|
{
|
|
Match = match,
|
|
Success = match != null
|
|
};
|
|
}
|
|
}
|
|
|
|
public class NewMatchResult : BaseCommandResult
|
|
{
|
|
/// <summary> Le match créé si success </summary>
|
|
public Match? Match { get; init; }
|
|
} |