コード例 #1
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 /// <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));
 }
コード例 #2
0
 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
     });
 }
コード例 #3
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
        public int Deletenaire(string[] Ids)
        {
            //防止注入式漏洞
            string ids = string.Join(",", Ids);

            DAL.Question dal = new DAL.Question();
            return(dal.Deletenaire(ids));
        }
コード例 #4
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
        //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*/));
        }
コード例 #5
0
ファイル: Question.cs プロジェクト: DevoraKister/ideal-client
 public static Entities.Question QuestionEntities(DAL.Question q)
 {
     return(new Entities.Question()
     {
         QueId = q.QueId,
         Question1 = q.Question1,
         QueTopicId = q.QueTopicId,
         QueUserId = q.QueUserId,
     });
 }
コード例 #6
0
ファイル: Write.cs プロジェクト: changyemenglv/rjgc
        //获取该问卷的表体

        public List <Model.Question> getNaireBody(int HeadId)
        {
            DAL.Question dal = new DAL.Question();
            return(dal.showNaireQuestion(HeadId));
        }
コード例 #7
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 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));
 }
コード例 #8
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 /// <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));
 }
コード例 #9
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 public Model.QuestionnaireHead GetQuestionnaire(int Id)
 {
     DAL.Question dal = new DAL.Question();
     return(dal.GetQuestionnaire(Id));
 }
コード例 #10
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 public Model.Question GetQustion(int Id)
 {
     DAL.Question dal = new DAL.Question();
     return(dal.GetQustion(Id));
 }
コード例 #11
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 //获取该问卷题目数量
 public int getQuestionCount(int HeadId)
 {
     DAL.Question dal = new DAL.Question();
     return(dal.getQuestionCount(HeadId));
 }
コード例 #12
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 public int deleteNaireQuestion(int Id)
 {
     DAL.Question dal = new DAL.Question();
     return(dal.deleteNaireQuestion(Id));
 }
コード例 #13
0
ファイル: Question.cs プロジェクト: changyemenglv/rjgc
 public int saveNaireQuestions(string[] Ids, string HeadId)
 {
     //string ids = string.Join(",", Ids);
     DAL.Question dal = new DAL.Question();
     return(dal.saveNaireQuestions(Ids, HeadId));
 }
コード例 #14
0
        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 }));
        }
コード例 #15
0
        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 }));
        }