public Team(TeamReadModel readModel) { this.ReadModel = readModel; Name = readModel.Name; Status = readModel.Status; }
private static TeamReadModel TeamReadModel(params Guid[] playerIds) { var teamReadModel = new TeamReadModel(); var trainerAsGuest = Guid.NewGuid(); teamReadModel.Handle(new TeamCreated(trainerAsGuest)); foreach (var playerId in playerIds) { teamReadModel.Handle(new PlayerBought(trainerAsGuest, playerId)); } return(teamReadModel); }
public DomainResult AddTeam(TeamReadModel teamId) { if (SeasonIsStarted) { return(DomainResult.Error(new SeasonAllreadyStarted())); } if (Teams.Any(t => t == teamId.TeamId)) { return(DomainResult.Error(new CanNotAddTeamTwice(teamId.TeamId))); } return(DomainResult.Ok(new TeamAddedToSeason(SeasonId, teamId.TeamId))); }
public Task <Team> AddTeam(Team team) { var readModel = new TeamReadModel(team.Identity) { Name = team.Name, Status = team.Status }; readModel.TransferDomainEvents(team); _dbContext.Teams.Add(readModel); team.ClearDomainEvents(); return(Task.FromResult(team)); }