public void CreateJudge(int eventID, string judgeUsername, string judgePassword, string judgeName) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { // Should find judge or school by username, instead of searching all though foreach (TblJudge j in GetAllJudges()) { if (judgeUsername.Equals(j.FldJudgeUsername)) { throw new UserNameAlreadyExistsException(judgeUsername); } } foreach (TblSchool s in GetAllSchools()) { if (judgeUsername.Equals(s.FldSchoolUsername)) { throw new UserNameAlreadyExistsException(judgeUsername); } } TblJudge judge = new TblJudge() { FldEventId = eventID, FldJudgeUsername = judgeUsername, FldJudgePassword = judgePassword, FldJudgeName = judgeName }; databaseContext.TblJudge.Add(judge); databaseContext.SaveChanges(); } }
public void DeleteSchool(TblSchool school) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { databaseContext.TblSchool.Remove(school); databaseContext.SaveChanges(); } }
public void DeleteJudge(TblJudge judge) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { databaseContext.TblJudge.Remove(judge); databaseContext.SaveChanges(); } }
private void DeleteAllExceptQuestions(DB_YoungEnterpriseContext databaseContext) { databaseContext.TblVoteAnswer.RemoveRange(databaseContext.TblVoteAnswer); databaseContext.TblVote.RemoveRange(databaseContext.TblVote); databaseContext.TblJudgePair.RemoveRange(databaseContext.TblJudgePair); databaseContext.TblJudge.RemoveRange(databaseContext.TblJudge); databaseContext.TblTeam.RemoveRange(databaseContext.TblTeam); databaseContext.TblSchool.RemoveRange(databaseContext.TblSchool); databaseContext.TblEvent.RemoveRange(databaseContext.TblEvent); databaseContext.SaveChanges(); }
private void CreateVoteAnswer(int questionID, int voteID) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { TblVoteAnswer voteAnswer = new TblVoteAnswer() { FldQuestionId = questionID, FldVoteId = voteID }; databaseContext.TblVoteAnswer.Add(voteAnswer); databaseContext.SaveChanges(); } }
public int CreateEvent(DateTime dateTime) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { DeleteAllExceptQuestions(databaseContext); TblEvent tblEvent = new TblEvent() { FldEventDate = dateTime }; databaseContext.TblEvent.Add(tblEvent); databaseContext.SaveChanges(); return(tblEvent.FldEventId); } }
public void CreateTeam(string teamName, int schoolID, string subject, byte[] report) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { TblTeam team = new TblTeam() { FldTeamName = teamName, FldSchoolId = schoolID, FldSubjectCategory = subject, FldReport = report }; databaseContext.TblTeam.Add(team); databaseContext.SaveChanges(); } }
private void CreateJudgePair(int judgeIdA, int judgeIdB) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { TblJudgePair judgePair = new TblJudgePair() { FldJudgeIda = judgeIdA, //FldJudgeIdaNavigation = judgeNavA, FldJudgeIdb = judgeIdB //FldJudgeIdbNavigation = judgeNavB }; databaseContext.TblJudgePair.Add(judgePair); databaseContext.SaveChanges(); } }
private int CreateVote(int judgePairID, string teamName, int points) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { TblVote vote = new TblVote() { FldJudgePairId = judgePairID, FldTeamName = teamName, FldPoints = points }; databaseContext.TblVote.Add(vote); databaseContext.SaveChanges(); return(vote.FldVoteId); } }
private void UpdateVote(int voteID, int judgePairID, string teamName, int points) { TblVote vote = null; using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { // Get existing vote using context vote = databaseContext.TblVote.Where(v => v.FldVoteId == voteID).FirstOrDefault <TblVote>(); // Change values if (vote != null) { vote.FldJudgePairId = judgePairID; vote.FldTeamName = teamName; vote.FldPoints = points; } // save changes using context. databaseContext.SaveChanges(); } }