コード例 #1
0
 public DbError DeleteTournament(TournamentModel tournament)
 {
     try
     {
         TournamentModel _tournament = context.Tournaments.Find(tournament.TournamentID);
         if (_tournament.TournamentRules != null)
         {
             TournamentRuleModel _rule = context.TournamentRules.Find(tournament.TournamentRules.TournamentRulesID);
             DeleteTournamentRules(_rule);
         }
         foreach (var bracket in _tournament.Brackets.ToList())
         {
             DeleteBracket(bracket);
         }
         foreach (var user in _tournament.Users.ToList())
         {
             RemoveUserFromTournament(_tournament, user);
         }
         context.Tournaments.Remove(_tournament);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         interfaceException = ex;
         WriteException(ex);
         return(DbError.FAILED_TO_DELETE);
     }
     return(DbError.SUCCESS);
 }
コード例 #2
0
 public DbError TournamentHasRules(TournamentModel tournament)
 {
     try
     {
         TournamentRuleModel tr = tournament.TournamentRules;
     }
     catch (Exception ex)
     {
         interfaceException = ex;
         WriteException(ex);
         return(DbError.DOES_NOT_EXIST);
     }
     return(DbError.EXISTS);
 }
コード例 #3
0
 public DbError DeleteTournamentRules(TournamentRuleModel tournamentRules)
 {
     try
     {
         TournamentRuleModel _rules = context.TournamentRules.Find(tournamentRules.TournamentRulesID);
         context.TournamentRules.Remove(_rules);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         interfaceException = ex;
         WriteException(ex);
         return(DbError.FAILED_TO_DELETE);
     }
     return(DbError.SUCCESS);
 }
コード例 #4
0
 public DbError UpdateRules(TournamentRuleModel tournamentRules)
 {
     try
     {
         TournamentRuleModel _tournamentRules = context.TournamentRules.Find(tournamentRules.TournamentRulesID);
         context.Entry(_tournamentRules).CurrentValues.SetValues(tournamentRules);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         interfaceException = ex;
         WriteException(ex);
         return(DbError.FAILED_TO_UPDATE);
     }
     return(DbError.SUCCESS);
 }
コード例 #5
0
        public DbError AddRulesToTournament(TournamentModel tounrnament, TournamentRuleModel tournamentRules)
        {
            try
            {
                context.TournamentRules.Add(tournamentRules);
                tounrnament.TournamentRules  = tournamentRules;
                tournamentRules.TournamentID = tounrnament.TournamentID;
                context.SaveChanges();
            }
            catch (Exception)
            {
                return(DbError.FAILED_TO_ADD);
            }

            return(DbError.SUCCESS);
        }
コード例 #6
0
        public DbError AddRules(ref TournamentRuleModel tournamentRules, TournamentModel tournament)
        {
            TournamentRuleModel rules = new TournamentRuleModel();

            try
            {
                rules = tournamentRules;
                context.TournamentRules.Add(tournamentRules);
                //context.SaveChanges();

                tournamentRules            = rules;
                tournament.TournamentRules = tournamentRules;
                //tournamentRules.TournamentID = tournament.TournamentID;

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                WriteException(ex);
                interfaceException = ex;
                return(DbError.FAILED_TO_ADD);
            }
            return(DbError.SUCCESS);
        }
コード例 #7
0
        public DbError AddTournament(TournamentModel tournament)
        {
            TournamentRuleModel _rules      = new TournamentRuleModel();
            TournamentModel     _tournament = new TournamentModel();

            try
            {
                _tournament = tournament;
                _rules      = tournament.TournamentRules;
                context.TournamentRules.Add(_rules);
                _tournament.CreatedOn    = DateTime.Now;
                _tournament.LastEditedOn = DateTime.Now;
                context.SaveChanges();
                context.Tournaments.Add(_tournament);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                interfaceException = ex;
                WriteException(ex);
                return(DbError.FAILED_TO_ADD);
            }
            return(DbError.SUCCESS);
        }