public PavlovServerPlayerListPublicViewModel PavlovServerPlayerListPublicViewModel(PavlovServerInfo serverInfo, IEnumerable <PavlovServerPlayer> players) { if (serverInfo == null) { return(null); } var model = new PavlovServerPlayerListPublicViewModel { ServerInfo = serverInfo, PlayerList = players.Select(x => new PavlovServerPlayer { Cash = x.Cash, KDA = x.KDA, Score = x.Score, TeamId = x.TeamId, UniqueId = x.UniqueId, Username = x.Username, Headshot = x.Headshot, Kills = x.Kills, Deaths = x.Deaths, Assists = x.Assists }).ToList(), team0Score = serverInfo.Team0Score, team1Score = serverInfo.Team1Score }; return(model); }
public async Task <IActionResult> SaveMatchResult(PavlovServerPlayerListPublicViewModel match) { var user = await _userservice.getUserFromCp(HttpContext.User); var servers = await _matchService.FindAllMatchesWhereTheUserHasRights(HttpContext.User, user); if (!servers.Select(x => x.Id).Contains(match.MatchId)) { return(Forbid()); } var realMatch = await _matchService.FindOne(match.MatchId); if (realMatch == null) { return(BadRequest("No match like that exists!")); } await _matchService.SaveMatchResult(match, realMatch); return(RedirectToAction("Index", "MatchMaking")); }