/// <summary> /// 保存增加的问题 /// </summary> /// <param name="Question"></param> /// <returns></returns> public int saveQuestion(string Question) { Model.Question question = new Model.Question(); question.Content = Question; DAL.Question dal = new DAL.Question(); return(dal.saveQuestion(question)); }
public static QuestionDTO ToDto(DAL.Question q) { return(new QuestionDTO() { questionDescription = q.questionDescription, levelQuestion = q.levelQuestion, questionId = q.questionId, categoriId = q.categoriId, teacherId = q.teacherId }); }
public int Deletenaire(string[] Ids) { //防止注入式漏洞 string ids = string.Join(",", Ids); DAL.Question dal = new DAL.Question(); return(dal.Deletenaire(ids)); }
//public List<Model.Teacher> GetTeacher(int SchoolId) //{ // DAL.Question dal = new DAL.Question(); // return dal.GetTeacher(SchoolId); //} public int AddSaveNaire(string QuestionnaireName, DateTime StartTime, DateTime EndTime, int SchoolName, /* int teacherName,*/ int className) { DAL.Question dal = new DAL.Question(); // int CourseId = dal.GetCourseId(teacherName); return(dal.AddSaveNaire(QuestionnaireName, StartTime, EndTime, SchoolName, /*teacherName,*/ className /*, CourseId*/)); }
public static Entities.Question QuestionEntities(DAL.Question q) { return(new Entities.Question() { QueId = q.QueId, Question1 = q.Question1, QueTopicId = q.QueTopicId, QueUserId = q.QueUserId, }); }
//获取该问卷的表体 public List <Model.Question> getNaireBody(int HeadId) { DAL.Question dal = new DAL.Question(); return(dal.showNaireQuestion(HeadId)); }
public int saveEditNaireQuestion(int Id, string EditQuestionnaireName, DateTime EditStartTime, DateTime EditEndTime, int EditSchool, /* int EditteacherName,*/ int EditclassName) { DAL.Question dal = new DAL.Question(); return(dal.saveEditNaireQuestion(Id, EditQuestionnaireName, EditStartTime, EditEndTime, EditSchool /*, EditteacherName*/, EditclassName)); }
/// <summary> /// 保存修改的信息 /// </summary> /// <param name="Id"></param> /// <param name="Content"></param> /// <returns></returns> public int saveEditContent(int Id, string Content) { DAL.Question dal = new DAL.Question(); return(dal.saveEditContent(Id, Content)); }
public Model.QuestionnaireHead GetQuestionnaire(int Id) { DAL.Question dal = new DAL.Question(); return(dal.GetQuestionnaire(Id)); }
public Model.Question GetQustion(int Id) { DAL.Question dal = new DAL.Question(); return(dal.GetQustion(Id)); }
//获取该问卷题目数量 public int getQuestionCount(int HeadId) { DAL.Question dal = new DAL.Question(); return(dal.getQuestionCount(HeadId)); }
public int deleteNaireQuestion(int Id) { DAL.Question dal = new DAL.Question(); return(dal.deleteNaireQuestion(Id)); }
public int saveNaireQuestions(string[] Ids, string HeadId) { //string ids = string.Join(",", Ids); DAL.Question dal = new DAL.Question(); return(dal.saveNaireQuestions(Ids, HeadId)); }
public async Task <IHttpActionResult> update(Models.EvaluationQuestionModel model) { if (!ModelState.IsValid) { return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) })); } Boolean result = true; try { System.Web.HttpContext.Current.Application.Lock(); var eval = _db.Evaluations.Where(p => p.id == model.id).FirstOrDefault(); eval.evaluationName = model.evaluationName; eval.description = model.description; _db.SaveChanges(); var questions = from q in _db.Questions where q.evaluationID == eval.id select q; foreach (var ques in questions) { //var choice = from ch in _db.Choice where ch.questionID == ques.id select ch; //foreach (var choiceDelete in choice) //{ // _db.Choice.Remove(choiceDelete); //} _db.Questions.Remove(ques); } _db.SaveChanges(); foreach (var q in model.questions) { DAL.Question quest = new DAL.Question(); quest.question1 = q.value; quest.evaluationID = model.id; _db.Questions.Add(quest); _db.SaveChanges(); //if (q.choices != null) //{ // List<DAL.Choice> chList = new List<DAL.Choice>(); // foreach (var ch in q.choices) // { // DAL.Question ques = _db.Question.Where(p => p.question1 == q.value && p.evaluationID == model.id).FirstOrDefault(); // DAL.Choice choice = new DAL.Choice(); // choice.choiceName = ch.value; // choice.questionID = ques.id; // chList.Add(choice); // } // _db.Choice.AddRange(chList); // _db.SaveChanges(); //} } System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { result = false; } return(Json(new { result = result })); }
public async Task <IHttpActionResult> create(Models.EvaluationQuestionModel model) { if (!ModelState.IsValid) { return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) })); } Boolean result = true; try { System.Web.HttpContext.Current.Application.Lock(); Evaluation eval = new Evaluation(); eval.evaluationName = model.evaluationName; eval.description = model.description; _db.Evaluations.Add(eval); int isSave = _db.SaveChanges(); if (isSave == 1) { Evaluation e = _db.Evaluations.Where(p => p.evaluationName == model.evaluationName).FirstOrDefault(); List <UserTypeInEvaluation> utList = new List <UserTypeInEvaluation>(); foreach (var uts in model.UserTypes) { var ut = _db.UserTypes.Where(p => p.UserTypeName == uts.userTypeName).FirstOrDefault(); UserTypeInEvaluation usertype = new UserTypeInEvaluation(); usertype.userTypeid = ut.UserTypeId; usertype.evaluationid = e.id; utList.Add(usertype); } _db.UserTypeInEvaluations.AddRange(utList); _db.SaveChanges(); foreach (var q in model.questions) { DAL.Question quest = new DAL.Question(); quest.question1 = q.value; quest.evaluationID = e.id; _db.Questions.Add(quest); _db.SaveChanges(); if (q.choices != null) { List <DAL.Choice> chList = new List <DAL.Choice>(); foreach (var ch in q.choices) { DAL.Question ques = _db.Questions.Where(p => p.question1 == q.value && p.evaluationID == e.id).FirstOrDefault(); DAL.Choice choice = new DAL.Choice(); choice.choiceName = ch.value; choice.questionID = ques.id; chList.Add(choice); } _db.Choices.AddRange(chList); _db.SaveChanges(); } } } System.Web.HttpContext.Current.Application.UnLock(); } catch (Exception e) { return(Json(e.Message)); } return(Json(new { result = result })); }