public void Handle(MatchResult4Registered e, string aggregateId) { // need to delete some entries ResultForPlayerReadModel[] modelsToDelete = DocumentSession.Load <ResultForPlayerReadModel>(e.PreviousPlayerIds.Select(x => ResultForPlayerReadModel.GetId(x, e.BitsMatchId, e.RosterId))); HashSet <string> toKeep = new(e.RosterPlayers.Select(x => ResultForPlayerReadModel.GetId(x, e.BitsMatchId, e.RosterId))); foreach (ResultForPlayerReadModel modelToDelete in modelsToDelete) { if (toKeep.Contains(modelToDelete.Id) == false) { DocumentSession.Delete(modelToDelete); } } Roster roster = DocumentSession.Load <Roster>(e.RosterId); foreach (string playerId in e.RosterPlayers) { string id = ResultForPlayerReadModel.GetId(playerId, e.BitsMatchId, e.RosterId); ResultForPlayerReadModel model = DocumentSession.Load <ResultForPlayerReadModel>(id); if (model == null) { model = new ResultForPlayerReadModel(roster.Season, playerId, e.BitsMatchId, roster.Id !, roster.Date); DocumentSession.Store(model); } model.Clear(); } }
private void Apply(MatchResult4Registered e) { RosterId = e.RosterId; TeamScore = e.TeamScore; OpponentScore = e.OpponentScore; BitsMatchId = e.BitsMatchId; rosterPlayers = new HashSet <string>(e.RosterPlayers); }
public void Handle(MatchResult4Registered e, string aggregateId) { Roster roster = DocumentSession.Load <Roster>(e.RosterId); string id = SeasonResults.GetId(roster.Season); SeasonResults seasonResults = DocumentSession.Load <SeasonResults>(id); if (seasonResults == null) { seasonResults = new SeasonResults(roster.Season); DocumentSession.Store(seasonResults); } seasonResults.RemoveWhere(e.BitsMatchId, e.RosterId); }
public void Handle(MatchResult4Registered e, string aggregateId) { Roster roster = DocumentSession.Load <Roster>(e.RosterId); string id = TeamOfWeek.IdFromBitsMatchId(e.BitsMatchId, e.RosterId); TeamOfWeek teamOfWeek = DocumentSession.Load <TeamOfWeek>(id); if (teamOfWeek == null) { teamOfWeek = new TeamOfWeek(e.BitsMatchId, roster.Season, roster.Id !); DocumentSession.Store(teamOfWeek); } teamOfWeek.Reset(); }
public void Handle(MatchResult4Registered e, string aggregateId) { DoRegister(aggregateId, e.RosterId, e.TeamScore, e.OpponentScore); }