public ActionResult QuestionADD(QuestionS te) { ef.Configuration.ProxyCreationEnabled = false; ef.Configuration.LazyLoadingEnabled = false; Teacher dong = Session["User"] as Teacher; Question an = new Question() { BookID = ef.TextBooks.FirstOrDefault(x => x.BookName == te.BookIDName).BookID, QuestionTitle = te.QuestionTitle, QuestionType = te.QuestionType == "单选题" ? false : true, QuestionLevel = te.QuestionLevel, ChapterID = ef.Chapters.FirstOrDefault(x => x.ChapterName == te.ChapterIDName).ChapterID, CreatorID = 2, CreateTime = DateTime.Now, IsCheck = false, Description = te.Description, Shan = false }; ef.Entry(an).State = EntityState.Added; if (ef.SaveChanges() > 0) { return(Content("成功")); } return(Content("失败")); }
public ActionResult ListDe(string Bian) { ef.Configuration.LazyLoadingEnabled = false; ef.Configuration.ProxyCreationEnabled = false; int bian = Convert.ToInt32(Bian); try { QuestionS te = Show().FirstOrDefault(x => x.QuestionID == bian); return(Json(te, JsonRequestBehavior.AllowGet)); } catch { return(Content("失败出现错误")); } }
public ActionResult QuestionADD(QuestionS te) { Question queBin = ef.Questions.FirstOrDefault(x => x.QuestionID == te.QuestionID && x.Shan == false); Teacher dong = Session["User"] as Teacher; queBin.BookID = ef.TextBooks.FirstOrDefault(x => x.BookName == te.BookIDName && x.Shan == false).BookID; queBin.QuestionTitle = te.QuestionTitle; queBin.QuestionType = te.QuestionType == "单选题" ? false : true; queBin.QuestionLevel = te.QuestionLevel; queBin.ChapterID = ef.Chapters.FirstOrDefault(x => x.ChapterName == te.ChapterIDName && x.Shan == false).ChapterID; queBin.IsCheck = true; queBin.CheckTime = DateTime.Now; queBin.CheckID = dong.TeacherID; queBin.Description = te.Description; ef.Entry(queBin).State = EntityState.Modified; if (ef.SaveChanges() > 0) { return(Content("成功")); } return(Content("失败")); }