public async Task <IActionResult> PutTblVoteAnswer([FromRoute] int id, [FromBody] TblVoteAnswer tblVoteAnswer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblVoteAnswer.FldVoteAnswerId) { return(BadRequest()); } _context.Entry(tblVoteAnswer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblVoteAnswerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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 List <TblVoteAnswer> FindQuestionsAndVotes(string questionCategory, string questionSubject, int judgePairId, string teamName) { List <TblVoteAnswer> result = new List <TblVoteAnswer>(); using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { foreach (TblQuestion question in FindQuestions(databaseContext, questionCategory, questionSubject)) { TblVote vote = FindJudgePairVotes(question.FldQuestionId, judgePairId, teamName); TblVoteAnswer voteAnswer = new TblVoteAnswer { FldQuestionId = question.FldQuestionId, Questiontext = question.FldQuestionText, QuestionModifier = question.FldQuestionModifier, FldVoteId = vote == null ? 0 : vote.FldVoteId, Points = vote == null ? 0 : vote.FldPoints }; result.Add(voteAnswer); } } return(result); }