コード例 #1
0
ファイル: DatabaseManager.cs プロジェクト: resitamas/EC2016
        public static void ModifyMatch(int id, int tournamentId, int homeTeamId, int awayTeamId, DateTime date, string type, int?homeScore, int?awayScore, bool isComfired)
        {
            using (var db = new EC2016CodeFirst())
            {
                Match match = db.Matches.Where(m => m.Id == id).First();
                match.TournamentId = tournamentId;
                match.HomeTeamId   = homeTeamId;
                match.AwayTeamId   = awayTeamId;
                match.Date         = date;
                match.Type         = type;
                match.HomeScore    = homeScore;
                match.AwayScore    = awayScore;
                match.isConfirmed  = isComfired;

                var entry = db.Entry(match);
                entry.Property(e => e.TournamentId).IsModified = true;
                entry.Property(e => e.HomeTeamId).IsModified   = true;
                entry.Property(e => e.AwayTeamId).IsModified   = true;
                entry.Property(e => e.Date).IsModified         = true;
                entry.Property(e => e.Type).IsModified         = true;
                entry.Property(e => e.HomeScore).IsModified    = true;
                entry.Property(e => e.AwayScore).IsModified    = true;
                entry.Property(e => e.isConfirmed).IsModified  = true;

                db.SaveChanges();
            }
        }
コード例 #2
0
ファイル: DatabaseManager.cs プロジェクト: resitamas/EC2016
        public static void ModifyGuess(string userId, int matchId, int homeScore, int awayScore)
        {
            using (var db = new EC2016CodeFirst())
            {
                Guess guess = db.Guesses.Where(g => g.UserId == userId && g.MatchId == matchId).First();
                guess.HomeScore = homeScore;
                guess.AwayScore = awayScore;

                db.Guesses.Attach(guess);
                var entry = db.Entry(guess);
                entry.Property(e => e.HomeScore).IsModified = true;
                entry.Property(e => e.AwayScore).IsModified = true;

                db.SaveChanges();
            }
        }
コード例 #3
0
ファイル: DatabaseManager.cs プロジェクト: resitamas/EC2016
        public static int AddResultForMatch(int matchId, int homeScore, int awayScore)
        {
            using (var db = new EC2016CodeFirst())
            {
                Match match = db.Matches.Where(m => m.Id == matchId).First();
                match.HomeScore = homeScore;
                match.AwayScore = awayScore;

                db.Matches.Attach(match);
                var entry = db.Entry(match);
                entry.Property(e => e.HomeScore).IsModified = true;
                entry.Property(e => e.AwayScore).IsModified = true;

                return(match.Id);
            }
        }