public Team(TeamReadModel readModel)
        {
            this.ReadModel = readModel;

            Name   = readModel.Name;
            Status = readModel.Status;
        }
예제 #2
0
        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);
        }
예제 #3
0
 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)));
 }
예제 #4
0
        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));
        }