public questionandanswer Add4(int id, questionandanswer question) { // 向试题表里增加试题 question = db.questionandanswer.Add(question); include_question_between_bank_and_questionandanswer tmp = new include_question_between_bank_and_questionandanswer { BankID = id, QuestionID = question.ID }; // 向题库里增加试题 db.include_question_between_bank_and_questionandanswer.Add(tmp); db.SaveChanges(); return(question); }
public bool Update4(int id, questionandanswer question) { questionandanswer tmp = db.questionandanswer.Where(p => p.ID == id).FirstOrDefault(); if (tmp != null) { // 修改 tmp.Content = question.Content; tmp.Answer = question.Answer; tmp.Score = question.Score; db.SaveChanges(); return(true); } else { return(false); } }