public ActionResult Index()
        {
            var allPlayers = _playerRepository.GetAllPlayers().ToList().Select(player => new PlayerViewModel
            {
                SteamId    = player.SteamId,
                NickName   = player.NickName,
                SteamImage = player.ImagePath,
                Rang       = player.Rang
            });
            var model = new AppStateModel
            {
                ApiPaths = Settings.ToJson(),
                Icons    = _strapiApi.GetAllImages()?
                           .Select(icon => new ImageViewModel
                {
                    Name  = icon.CodeName,
                    Image = icon.Image.FullUrl
                }).ToJson(),
                Weapons = _strapiApi.GetAllWeapons()?
                          .Select(weapon => new WeaponViewModel
                {
                    Id         = weapon.Id,
                    Name       = weapon.Name,
                    IconImage  = weapon.Icon.FullUrl,
                    PhotoImage = weapon.Image.FullUrl,
                    Type       = weapon.Type.Name
                }).ToJson(false, true),
                Players = allPlayers.ToJson()
            };

            return(View(model));
        }
        public ActionResult GetMatch(string matchId)
        {
            if (matchId.IsNotEmpty())
            {
                var match  = _demoRepository.GetMatch(matchId);
                var images = _strapiApi.GetAllImages();

                if (match == null)
                {
                    return(Json("Match not found"));
                }

                var playerStatByRounds = match.Rounds.SelectMany(round => round.Squads.SelectMany(squad =>
                                                                                                  squad.Players.Select(player =>
                                                                                                                       new PlayerStatByRound
                {
                    RoundNumber = round.RoundNumber,
                    SteamId     = player.SteamID,
                    Kills       = player.Kills.Where(x => !x.IsSuicide).ToList().Count -
                                  player.Kills.Where(x => x.IsSuicide).ToList().Count,
                    Assists       = player.Assists.Count,
                    Death         = player.Deaths.Count,
                    Damage        = player.Damage.Sum(x => x.HealthDamage),
                    UtilityDamage = player.UtilityDamage.Sum(x => x.HealthDamage),
                    Score         = GetScore(player)
                }))).ToList();

                var matchDetails = new MatchDetails
                {
                    Id       = match.Id,
                    Map      = match.Map,
                    MapImage = GetMapImage(match.Map),
                    Date     = match.MatchDate,
                    AScore   = match.TotalSquadAScore,
                    BScore   = match.TotalSquadBScore,
                    Duration = match.Duration,
                    Rounds   = match.Rounds.Select(round => new MatchRound
                    {
                        Id            = round.RoundNumber,
                        CTScore       = round.CTScore,
                        TScore        = round.TScore,
                        Reason        = (int)round.Reason,
                        ReasonTitle   = round.ReasonTitle,
                        Duration      = round.Duration,
                        ReasonIconUrl = images.FirstOrDefault(x => string.Equals(x.CodeName, round.ReasonTitle, StringComparison.InvariantCultureIgnoreCase))?.Image.FullUrl,
                        Kills         = round.Squads
                                        .SelectMany(squad => squad.Players
                                                    .SelectMany(player => player.Kills
                                                                .Select((kill, index) => new MatchDetailsKill
                        {
                            Id           = index,
                            Killer       = player.SteamID.ToString(),
                            Victim       = kill.Victim?.ToString(),
                            Assister     = kill.Assister?.ToString(),
                            Weapon       = kill.Weapon,
                            IsSuicide    = kill.IsSuicide,
                            IsHeadshot   = kill.IsHeadshot,
                            Time         = kill.Time,
                            IsPenetrated = kill.IsPenetrated
                        })
                                                                )).OrderBy(x => x.Time).ToList(),
                        Squads = round.Squads.Select((squad, index) => new MatchDetailsSquad
                        {
                            Id      = index,
                            Title   = squad.SquadTitle,
                            Players = squad.Players.Select(player => new MatchDetailsSquadPlayer
                            {
                                Id    = player.SteamID.ToString(),
                                Team  = squad.Team,
                                Kills = playerStatByRounds
                                        .Where(x => x.SteamId == player.SteamID && x.RoundNumber <= round.RoundNumber)
                                        .Sum(t => t.Kills),
                                Deaths = playerStatByRounds
                                         .Where(x => x.SteamId == player.SteamID && x.RoundNumber <= round.RoundNumber)
                                         .Sum(t => t.Death),
                                Assists = playerStatByRounds
                                          .Where(x => x.SteamId == player.SteamID && x.RoundNumber <= round.RoundNumber)
                                          .Sum(t => t.Assists),
                                Adr = Convert.ToInt32(Math.Round(
                                                          playerStatByRounds.Where(x => x.SteamId == player.SteamID &&
                                                                                   x.RoundNumber <= round.RoundNumber)
                                                          .Sum(t => t.Damage) / (double)round.RoundNumber)),
                                Ud = playerStatByRounds.Where(x => x.SteamId == player.SteamID &&
                                                              x.RoundNumber <= round.RoundNumber)
                                     .Sum(t => t.UtilityDamage),
                                Score = playerStatByRounds
                                        .Where(x => x.SteamId == player.SteamID && x.RoundNumber <= round.RoundNumber)
                                        .Sum(t => t.Score),
                                IsDied = playerStatByRounds
                                         .First(x => x.SteamId == player.SteamID && x.RoundNumber == round.RoundNumber)
                                         .Death > 0
                            }).OrderByDescending(player => player.Score).ToList()
                        }).OrderByDescending(x => x.Title).ToList()
                    }).ToList()
                };

                _matchDummyCacheManager.AddDependency(matchId);
                return(Json(matchDetails));
            }

            return(Json("missing match id"));
        }