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); }
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); }