/// <summary> /// Create a new answer object. /// </summary> /// <param name="answerID">Initial value of the answerID property.</param> /// <param name="answer1">Initial value of the answer1 property.</param> /// <param name="questionID">Initial value of the questionID property.</param> public static answer Createanswer(global::System.Int32 answerID, global::System.String answer1, global::System.Int32 questionID) { answer answer = new answer(); answer.answerID = answerID; answer.answer1 = answer1; answer.questionID = questionID; return(answer); }
//Delete Answer by id public string deleteAnswerById(int id) { try { CommonLayer.answer ans = getAnswerByID(id); this.Entity.answers.DeleteObject(ans); this.Entity.SaveChanges(); return("Answer Deleted :)"); } catch (Exception ex) { return(ex.Message); } }
//Add Answer public string AddAnswer(string answer) { try { CommonLayer.answer ans = new CommonLayer.answer(); ans.answer1 = answer; this.Entity.answers.AddObject(ans); this.Entity.SaveChanges(); return("Answer Added Successfully"); } catch (Exception ex) { return(ex.Message); } }
//Add Answer public string AddAnswer(string answer) { try { CommonLayer.answer ans = new CommonLayer.answer(); ans.answer1 = answer; this.Entity.answers.AddObject(ans); this.Entity.SaveChanges(); return "Answer Added Successfully"; } catch (Exception ex) { return ex.Message; } }
//Add Question to database public string addQuestion(string questionName, int quizID, List <string> answers) { try { CommonLayer.question quest = new CommonLayer.question(); quest.question1 = questionName; quest.quizID = quizID; this.Entity.questions.AddObject(quest); this.Entity.SaveChanges(); int id = -1; //searxh in list of answers foreach (string name in answers) { CommonLayer.answer a = new CommonLayer.answer(); a.answer1 = name; a.questionID = quest.questionID; this.Entity.answers.AddObject(a); this.Entity.SaveChanges(); id = a.answerID; } // Add questions. CommonLayer.question uquest = getQuestionById(quest.questionID); uquest.correctAnswerID = id; this.Entity.SaveChanges(); return("Success"); } catch (Exception ex) { return(ex.Message); } }
//Add Question to database public string addQuestion(string questionName, int quizID, List<string> answers) { try { CommonLayer.question quest = new CommonLayer.question(); quest.question1 = questionName; quest.quizID = quizID; this.Entity.questions.AddObject(quest); this.Entity.SaveChanges(); int id = -1; //searxh in list of answers foreach (string name in answers) { CommonLayer.answer a = new CommonLayer.answer(); a.answer1 = name; a.questionID = quest.questionID; this.Entity.answers.AddObject(a); this.Entity.SaveChanges(); id= a.answerID; } // Add questions. CommonLayer.question uquest = getQuestionById(quest.questionID); uquest.correctAnswerID = id; this.Entity.SaveChanges(); return "Success"; } catch (Exception ex) { return ex.Message; } }
/// <summary> /// Create a new answer object. /// </summary> /// <param name="answerID">Initial value of the answerID property.</param> /// <param name="answer1">Initial value of the answer1 property.</param> /// <param name="questionID">Initial value of the questionID property.</param> public static answer Createanswer(global::System.Int32 answerID, global::System.String answer1, global::System.Int32 questionID) { answer answer = new answer(); answer.answerID = answerID; answer.answer1 = answer1; answer.questionID = questionID; return answer; }
/// <summary> /// Deprecated Method for adding a new object to the answers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToanswers(answer answer) { base.AddObject("answers", answer); }