Beispiel #1
0
        private ActionResult <MatchResponse> UpdateMatch(Match lastMatch)
        {
            var game     = _schotten2Service.Load(lastMatch.Id.ToString());
            var status   = game.WinnerId == null ? MatchStatus.InProgress : MatchStatus.Finished;
            var attacker = new PlayerResultModel {
                PlayerId = game.AttackerId,
                Score    = game.AttackerId == game.WinnerId ? 1 : 0,
                Status   = status
            };
            var defender = new PlayerResultModel {
                PlayerId = game.DefenderId,
                Score    = game.DefenderId == game.WinnerId ? 1 : 0,
                Status   = status
            };
            var result = new ResultModel {
                Status  = status,
                Players = new List <PlayerResultModel>()
                {
                    attacker, defender
                }
            };

            return(_matchService.UpdateMatch(lastMatch, result));
        }