public ActionResult MatchInsert(int tournamentId, MatchModel match) { var tournament = _tournamentService.GetById(tournamentId); var newMatch = new Match(); newMatch.Club = _tennisClubService.GetById(3);// Mapper.Map<TennisClubModel, TennisClub>(_tennisClubService.GetAll().First()); newMatch.Club.Address = _addressService.GetById(2); newMatch.Player1 = _playerService.GetById(match.Player1.Id); newMatch.Player2 = _playerService.GetById(match.Player2.Id); newMatch.Stage = match.Stage; if (match.StartDateTime > Constants.MinimalSqlDate) { newMatch.StartDateTime = match.StartDateTime; } else { newMatch.StartDateTime = Constants.MinimalSqlDate; } ParseMatchResult(newMatch, match.MatchResultDisplay); _tournamentService.AddMatch(tournament, newMatch); return Json(tournament); }
public ActionResult ResultUpdate(int tournamentId, MatchModel match) { var tournament = _tournamentService.GetById(tournamentId); var updatedMatch = _tournamentService.GetMatchById(tournamentId, match.Id); updatedMatch.Player1 = _playerService.GetById(match.Player1.Id); updatedMatch.Player2 = _playerService.GetById(match.Player2.Id); updatedMatch.Stage = match.Stage; if (match.StartDateTime > Constants.MinimalSqlDate) { updatedMatch.StartDateTime = match.StartDateTime; } else { updatedMatch.StartDateTime = Constants.MinimalSqlDate; } updatedMatch.CompletionReason = match.MatchResultDisplay; _tournamentService.UpdateMatch(tournament, updatedMatch); return Json(tournament); }
public ActionResult MatchComplete(int tournamentId, MatchModel match) { var tournament = _tournamentService.GetById(tournamentId); var updatedMatch = _tournamentService.GetMatchById(tournamentId, match.Id); updatedMatch.CompletionReason = match.CompletionReason; updatedMatch.WinnerId = match.WinnerId; _tournamentService.UpdateMatch(tournament, updatedMatch); return Json(tournament); }