public MatchModel GetMatch(int matchId) { MatchModel match = new MatchModel(); try { match = context.MatchModels.Find(matchId); match.Challenger = context.TournamentUserModels.Find(match.ChallengerID); match.Defender = context.TournamentUserModels.Find(match.DefenderID); } catch (Exception ex) { interfaceException = ex; WriteException(ex); match = null; } return(match); }
public DbError DeleteMatch(int matchId) { try { MatchModel _match = context.MatchModels.Find(matchId); foreach (var game in _match.Games.ToList()) { context.GameModels.Remove(game); } context.MatchModels.Remove(_match); context.SaveChanges(); } catch (Exception ex) { interfaceException = ex; WriteException(ex); return(DbError.FAILED_TO_DELETE); } return(DbError.SUCCESS); }