public DbError UpdateMatch(MatchModel match) { try { MatchModel _match = context.Matches.Find(match.MatchID); _match.Challenger = context.Users.Find(match.ChallengerID); _match.Defender = context.Users.Find(match.DefenderID); context.Entry(_match).CurrentValues.SetValues(match); context.SaveChanges(); } catch (Exception ex) { interfaceException = ex; WriteException(ex); return(DbError.FAILED_TO_UPDATE); } return(DbError.SUCCESS); }
public List <MatchModel> GetMatchsBySeriesId() { List <MatchModel> matchModels = new List <MatchModel>(); var seriesMatchs = (from m in challengeEntities.Matches where m.SeriesId == seriesId select new { m }).ToList(); if (seriesMatchs != null && seriesMatchs.Count > 0) { foreach (var eachRow in seriesMatchs) { MatchModel seriesMatch = new MatchModel(); seriesMatch = JsonConvert.DeserializeObject <MatchModel>(JsonConvert.SerializeObject(eachRow.m)); matchModels.Add(seriesMatch); } } return(matchModels); }
public List <GameModel> GetAllGamesInMatch(MatchModel match) { List <GameModel> games = new List <GameModel>(); try { games = match.Games.ToList(); } catch (Exception ex) { interfaceException = ex; WriteException(ex); games.Clear(); games.Add(new GameModel() { GameID = -1 }); } return(games); }