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 async Task <IActionResult> PostTblJudge([FromBody] TblJudge tblJudge) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TblJudge.Add(tblJudge); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TblJudgeExists(tblJudge.FldJudgeLetter)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetTblJudge", new { id = tblJudge.FldJudgeLetter }, tblJudge)); }
public async Task <IActionResult> PutTblJudge([FromRoute] string id, [FromBody] TblJudge tblJudge) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblJudge.FldJudgeLetter) { return(BadRequest()); } _context.Entry(tblJudge).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblJudgeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void DeleteJudge(TblJudge judge) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { databaseContext.TblJudge.Remove(judge); databaseContext.SaveChanges(); } }
public TblJudge GET(string username) { string judgeletter = _context.TblJudge.Where(n => n.FldUsername == username).First().FldJudgeLetter; var returnletter = new TblJudge { FldJudgeLetter = judgeletter }; return(returnletter); }
public int GetJudgePairID(string judgeUsername) { List <TblJudge> judges = GetAllJudges(); List <TblJudgePair> judgePairs = GetAllJudgePairs(); TblJudge selectedJudge = new TblJudge(); foreach (TblJudge judge in judges) { if (judge.FldJudgeUsername.Equals(judgeUsername)) { selectedJudge = judge; break; } } TblJudgePair selectedJudgePair = null; foreach (TblJudgePair judgePair in judgePairs) { if (judgePair.FldJudgeIda == selectedJudge.FldJudgeId || judgePair.FldJudgeIdb == selectedJudge.FldJudgeId) { selectedJudgePair = judgePair; break; } } if (selectedJudgePair == null) { return(0); } else { return(selectedJudgePair.FldJudgePairId); } }