コード例 #1
0
    public void Handle(Serie4Registered e, string aggregateId)
    {
        string id = ResultSeries4ReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeries4ReadModel results = DocumentSession.Load <ResultSeries4ReadModel>(id);

        MatchSerie4 matchSerie = e.MatchSerie;

        string[] playerIds = new[]
        {
            matchSerie.Game1.Player,
            matchSerie.Game2.Player,
            matchSerie.Game3.Player,
            matchSerie.Game4.Player
        };

        Dictionary <string, Player> players = DocumentSession.Load <Player>(playerIds).ToDictionary(x => x.Id);

        ResultSeries4ReadModel.Game game1 = CreateGame(players, matchSerie.Game1);
        ResultSeries4ReadModel.Game game2 = CreateGame(players, matchSerie.Game2);
        ResultSeries4ReadModel.Game game3 = CreateGame(players, matchSerie.Game3);
        ResultSeries4ReadModel.Game game4 = CreateGame(players, matchSerie.Game4);

        results.Series.Add(new ResultSeries4ReadModel.Serie
        {
            Games = new List <ResultSeries4ReadModel.Game>
            {
                game1,
                game2,
                game3,
                game4
            }
        });
    }
コード例 #2
0
    public ActionResult Details(int id, string rosterId)
    {
        string headerId = ResultHeaderReadModel.IdFromBitsMatchId(id, rosterId);
        ResultHeaderReadModel headerReadModel = CompositionRoot.DocumentSession.Load <ResultHeaderReadModel>(headerId);

        if (headerReadModel == null)
        {
            throw new HttpException(404, "Match result not found");
        }

        Roster roster = CompositionRoot.DocumentSession.Load <Roster>(headerReadModel.RosterId);
        ResultHeaderViewModel headerViewModel = new(headerReadModel, roster);

        if (roster.IsFourPlayer)
        {
            string matchId = ResultSeries4ReadModel.IdFromBitsMatchId(id, rosterId);
            ResultSeries4ReadModel resultReadModel = CompositionRoot.DocumentSession.Load <ResultSeries4ReadModel>(matchId)
                                                     ?? new ResultSeries4ReadModel();

            return(View("Details4", new Result4ViewModel(headerViewModel, resultReadModel)));
        }
        else
        {
            string matchId = ResultSeriesReadModel.IdFromBitsMatchId(id, rosterId);
            ResultSeriesReadModel resultReadModel = CompositionRoot.DocumentSession.Load <ResultSeriesReadModel>(matchId)
                                                    ?? new ResultSeriesReadModel();

            return(View(new ResultViewModel(headerViewModel, resultReadModel)));
        }
    }
コード例 #3
0
    public void Handle(MatchResult4Registered e, string aggregateId)
    {
        string id = ResultSeries4ReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeries4ReadModel results = DocumentSession.Load <ResultSeries4ReadModel>(id);

        if (results == null)
        {
            results = new ResultSeries4ReadModel {
                Id = id
            };
            DocumentSession.Store(results);
        }

        results.Clear();
    }
コード例 #4
0
 public Result4ViewModel(ResultHeaderViewModel headerViewModel, ResultSeries4ReadModel resultReadModel)
 {
     HeaderViewModel = headerViewModel ?? throw new ArgumentNullException(nameof(headerViewModel));
     ResultReadModel = resultReadModel ?? throw new ArgumentNullException(nameof(resultReadModel));
 }