public ActionResult Create(QUESTION question) { if (question.question_text == "") { ModelState.AddModelError("question_text", "This is a required field."); } if (question.answer_type_id == 0) { ModelState.AddModelError("answer_type_id", "This is a required field."); } question.user_stamp = 1; question.datestamp = DateTime.Now; int answerType = question.answer_type_id; if (ModelState.IsValid) { db.QUESTIONs.AddObject(question); db.SaveChanges(); //NEEDS to bE FIXED //this needs to check the answer type name and not in index in the database //there is no guarentee the numbers are the same if ((answerType == 2) || (answerType == 3)) { var choices = new Survey.Models.MultipleChoiceItem(); choices.QID = question.question_id; choices.Questiontext = question.question_text; return RedirectToAction("MultipleChoiceCreate", choices); } } return RedirectToAction("Index"); }
/// <summary> /// Deprecated Method for adding a new object to the QUESTIONs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQUESTIONs(QUESTION qUESTION) { base.AddObject("QUESTIONs", qUESTION); }
/// <summary> /// Create a new QUESTION object. /// </summary> /// <param name="question_id">Initial value of the question_id property.</param> /// <param name="question_text">Initial value of the question_text property.</param> /// <param name="answer_type_id">Initial value of the answer_type_id property.</param> /// <param name="datestamp">Initial value of the datestamp property.</param> /// <param name="user_stamp">Initial value of the user_stamp property.</param> public static QUESTION CreateQUESTION(global::System.Int32 question_id, global::System.String question_text, global::System.Int32 answer_type_id, global::System.DateTime datestamp, global::System.Int32 user_stamp) { QUESTION qUESTION = new QUESTION(); qUESTION.question_id = question_id; qUESTION.question_text = question_text; qUESTION.answer_type_id = answer_type_id; qUESTION.datestamp = datestamp; qUESTION.user_stamp = user_stamp; return qUESTION; }
public ActionResult Edit(QUESTION question) { question.datestamp = DateTime.Now; if (ModelState.IsValid) { db.QUESTIONs.Attach(question); db.ObjectStateManager.ChangeObjectState(question, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(question); }