public IActionResult MAPost(MatchAdd matchToAdd) { if (matchToAdd.win == matchToAdd.lose || matchToAdd.win == null || matchToAdd.lose == null) { ViewBag.PostResultText = "Матч не добавлен! Участники заданы неверно."; ViewBag.PostResult = "0"; return(View()); } int PONewRating = 0; int PTNewRating = 0; if (matchToAdd.time == new DateTime(1, 1, 1, 0, 0, 0)) { matchToAdd.time = DateTime.Now; } Match newMatch = new Match { Time = matchToAdd.time, Comment = matchToAdd.comment + "" }; MatchParticipant ParticipantOne = new MatchParticipant { player = Convert.ToString(matchToAdd.win), matchID = Convert.ToInt32(newMatch.Id), result = 1 }; MatchParticipant ParticipantTwo = new MatchParticipant { player = Convert.ToString(matchToAdd.lose), matchID = Convert.ToInt32(newMatch.Id), result = 0 }; PONewRating = _allPlayers.GetPlayerByAlias(matchToAdd.win).Rating; PTNewRating = _allPlayers.GetPlayerByAlias(matchToAdd.lose).Rating; ELO.CalculateELO(ref PONewRating, ref PTNewRating, 1); ELO.CalculateELO(ref PTNewRating, ref PONewRating, 0); //POne.Rating = PONewRating; //PTwo.Rating = PONewRating; _allPlayers.UpdateRating(PONewRating, matchToAdd.win); _allPlayers.UpdateRating(PTNewRating, matchToAdd.lose); PONewRating = 0; PTNewRating = 0; _AddMatch.AddMatch(matchToAdd, newMatch, ParticipantOne, ParticipantTwo); //ViewBag.AP = _allPlayers.AllPlayers PlayersListViewModel PListed = new PlayersListViewModel(); PListed.GetAllPlayers = _allPlayers.AllPlayers; ViewBag.PostResultText = "Матч добавлен!"; ViewBag.PostResult = "1"; return(View()); }