Beispiel #1
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)));
        }
    }
Beispiel #2
0
    public void Handle(MatchResultRegistered e, string aggregateId)
    {
        string id = ResultSeriesReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeriesReadModel results = DocumentSession.Load <ResultSeriesReadModel>(id);

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

        results.Clear();
    }
Beispiel #3
0
    public override async Task Handle(HandlerContext <Command> context)
    {
        Roster roster = CompositionRoot.DocumentSession.Load <Roster>(context.Payload.RosterId);

        if (roster.IsFourPlayer)
        {
            return;
        }

        string resultSeriesReadModelId = ResultSeriesReadModel.IdFromBitsMatchId(roster.BitsMatchId, roster.Id !);
        ResultSeriesReadModel resultSeriesReadModel = CompositionRoot.DocumentSession.Load <ResultSeriesReadModel>(resultSeriesReadModelId);
        string resultHeaderReadModelId = ResultHeaderReadModel.IdFromBitsMatchId(roster.BitsMatchId, roster.Id !);
        ResultHeaderReadModel resultHeaderReadModel = CompositionRoot.DocumentSession.Load <ResultHeaderReadModel>(resultHeaderReadModelId);
        MatchRegisteredEmail  email = new(
            roster.Team,
            roster.Opponent !,
            context.Payload.Score,
            context.Payload.OpponentScore,
            resultSeriesReadModel,
            resultHeaderReadModel);
        await CompositionRoot.EmailService.SendAsync(email);
    }
Beispiel #4
0
        private async Task <IHttpActionResult> Handle(MatchRegisteredEvent @event)
        {
            Roster roster = DocumentSession.Load <Roster>(@event.RosterId);

            if (roster.IsFourPlayer)
            {
                return(Ok());
            }
            string resultSeriesReadModelId = ResultSeriesReadModel.IdFromBitsMatchId(roster.BitsMatchId, roster.Id);
            ResultSeriesReadModel resultSeriesReadModel = DocumentSession.Load <ResultSeriesReadModel>(resultSeriesReadModelId);
            string resultHeaderReadModelId = ResultHeaderReadModel.IdFromBitsMatchId(roster.BitsMatchId, roster.Id);
            ResultHeaderReadModel resultHeaderReadModel = DocumentSession.Load <ResultHeaderReadModel>(resultHeaderReadModelId);
            await Emails.MatchRegistered(
                roster.Team,
                roster.Opponent,
                @event.Score,
                @event.OpponentScore,
                resultSeriesReadModel,
                resultHeaderReadModel);

            return(Ok());
        }
Beispiel #5
0
    public void Handle(SerieRegistered e, string aggregateId)
    {
        string id = ResultSeriesReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeriesReadModel results = DocumentSession.Load <ResultSeriesReadModel>(id);

        MatchSerie       matchSerie = e.MatchSerie;
        HashSet <string> playerIds  = new()
        {
            matchSerie.Table1.Game1.Player,
            matchSerie.Table1.Game2.Player,
            matchSerie.Table2.Game1.Player,
            matchSerie.Table2.Game2.Player,
            matchSerie.Table3.Game1.Player,
            matchSerie.Table3.Game2.Player,
            matchSerie.Table4.Game1.Player,
            matchSerie.Table4.Game2.Player
        };

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

        ResultSeriesReadModel.Table table1 = CreateTable(players, matchSerie.Table1);
        ResultSeriesReadModel.Table table2 = CreateTable(players, matchSerie.Table2);
        ResultSeriesReadModel.Table table3 = CreateTable(players, matchSerie.Table3);
        ResultSeriesReadModel.Table table4 = CreateTable(players, matchSerie.Table4);

        results.Series.Add(new ResultSeriesReadModel.Serie
        {
            Tables = new List <ResultSeriesReadModel.Table>
            {
                table1,
                table2,
                table3,
                table4
            }
        });
    }