コード例 #1
0
        public QuestionListResponse updateQuestion(Question question)
        {
            QuestionListResponse  response = new QuestionListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                var idList = question.QuestionOption.Select(r => r.ID).ToList();

                db.QuestionOption.RemoveRange(db.QuestionOption.Where(r => r.QuestionID == question.ID && !idList.Contains(r.ID)));

                foreach (var item in question.QuestionOption)
                {
                    if (item.ID != 0)
                    {
                        db.QuestionOption.Attach(item);
                        db.Entry(item).State = EntityState.Modified;
                    }
                    else
                    {
                        item.QuestionID = question.ID;
                        db.QuestionOption.Add(item);
                        db.SaveChanges();
                    }
                }



                db.Question.Attach(question);
                db.Entry(question).State = EntityState.Modified;

                db.SaveChanges();
                question.QuestionType = db.QuestionType.Where(r => r.ID == question.QuestionTypeID).FirstOrDefault();
                response.questions.Add(question);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #2
0
        public QuestionListResponse getQuestionFromSubjectID(int subjectID, int diffiCultyID)
        {
            QuestionListResponse  response = new QuestionListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                response.questions = db.Question.Where(r => r.SubjectID == subjectID && r.DifficultyID == diffiCultyID && r.State == true).ToList();
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #3
0
        public EducationProgramListResponse addEducationProgram(EducationProgram educationProgram)
        {
            EducationProgramListResponse response = new EducationProgramListResponse();
            QuestionProjeEntities        db       = new QuestionProjeEntities();

            try
            {
                db.EducationProgram.Add(educationProgram);
                db.SaveChanges();
                response.educationPrograms.Add(educationProgram);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }

            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #4
0
        public DifficultyListResponse getDifficultyAll()
        {
            DifficultyListResponse response = new DifficultyListResponse();
            QuestionProjeEntities  db       = new QuestionProjeEntities();

            db.Configuration.ProxyCreationEnabled = false;
            try
            {
                response.difficultys = db.Difficulty.Where(r => r.State == true).ToList();
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #5
0
        public SubjectListResponse getSubjectFromLessonID(int lessonID)
        {
            SubjectListResponse   response = new SubjectListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            db.Configuration.ProxyCreationEnabled = false;
            try
            {
                response.subjects = db.Subject.Where(r => r.LessonID == lessonID && r.State == true).ToList();
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #6
0
        public DifficultyListResponse addDifficulty(Difficulty difficulty)
        {
            DifficultyListResponse response = new DifficultyListResponse();
            QuestionProjeEntities  db       = new QuestionProjeEntities();

            try
            {
                db.Difficulty.Add(difficulty);
                db.SaveChanges();
                response.difficultys.Add(difficulty);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #7
0
        public SubjectListResponse addSubject(Subject subject)
        {
            SubjectListResponse   response = new SubjectListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Subject.Add(subject);
                db.SaveChanges();
                response.subjects.Add(subject);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #8
0
        public LessonListResponse addLesson(Lesson lesson)
        {
            LessonListResponse    response = new LessonListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Lesson.Add(lesson);
                db.SaveChanges();
                response.lessions.Add(lesson);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #9
0
        public EducationProgramListResponse deleteEducationProgram(int ID)
        {
            EducationProgramListResponse response = new EducationProgramListResponse();
            QuestionProjeEntities        db       = new QuestionProjeEntities();

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                EducationProgram educationProgram = db.EducationProgram.Where(r => r.ID == ID).SingleOrDefault();
                educationProgram.State = false;
                db.SaveChanges();
                response.educationPrograms.Add(educationProgram);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }

            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #10
0
        public QuestionListResponse addQuestion(Question question)
        {
            QuestionListResponse  response = new QuestionListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Question.Add(question);
                db.SaveChanges();
                question.QuestionType = db.QuestionType.Where(r => r.ID == question.QuestionTypeID).FirstOrDefault();
                response.questions.Add(question);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #11
0
        public DifficultyListResponse deleteDifficulty(int ID)
        {
            DifficultyListResponse response = new DifficultyListResponse();
            QuestionProjeEntities  db       = new QuestionProjeEntities();

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                Difficulty difficulty = db.Difficulty.Where(r => r.ID == ID).SingleOrDefault();
                difficulty.State = false;
                db.SaveChanges();
                response.difficultys.Add(difficulty);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }

            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #12
0
        public SubjectListResponse deleteSubject(int ID)
        {
            SubjectListResponse   response = new SubjectListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                Subject subject = db.Subject.Where(r => r.ID == ID).SingleOrDefault();
                subject.State = false;
                db.SaveChanges();
                response.subjects.Add(subject);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }

            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #13
0
        public LessonListResponse deleteLesson(int ID)
        {
            LessonListResponse    response = new LessonListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                Lesson lesson = db.Lesson.Where(r => r.ID == ID).SingleOrDefault();
                lesson.State = false;
                db.SaveChanges();
                response.lessions.Add(lesson);
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }

            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #14
0
        public QuestionListResponse getQuestionFromFilters(List <ExamFilterModel> filters)
        {
            QuestionListResponse  response = new QuestionListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                QuestionListResponse qList = new QuestionListResponse();
                foreach (var filter in filters)
                {
                    var idList   = qList.questions.Select(c => c.ID);
                    var question = db.Question.Where(r => r.State == true && !idList.Contains(r.ID));

                    if (filter.EducationProgramID != -1 && question == null)
                    {
                        question = question.Where(r => r.EducationProgramID == filter.EducationProgramID);
                    }

                    if (filter.LessonID != -1)
                    {
                        question = question.Where(r => r.LessonID == filter.LessonID);
                    }

                    if (filter.SubjectID != -1)
                    {
                        question = question.Where(r => r.SubjectID == filter.SubjectID);
                    }

                    if (filter.DifficultyID != -1)
                    {
                        question = question.Where(r => r.DifficultyID == filter.DifficultyID);
                    }

                    if (filter.QuestionTypeID != -1)
                    {
                        question = question.Where(r => r.QuestionTypeID == filter.QuestionTypeID);
                    }

                    if (filter.LanguageID != -1)
                    {
                        question = question.Where(r => r.LanguageID == filter.LanguageID);
                    }

                    if (filter.QuestionCount != -1)
                    {
                        question = question.OrderBy(r => Guid.NewGuid()).Take(filter.QuestionCount);
                    }


                    if (filter.QuestionOptionCount != -1)
                    {
                        question = question.Where(r => r.QuestionOption.Count == filter.QuestionOptionCount);
                    }

                    qList.questions.AddRange(question.ToList());
                }

                response.questions = qList.questions;
            }
            catch (Exception ex)
            {
                //bir hata olursa response set edilsin
                Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SYSTEM_ERROR, response);
                return(response);
            }


            //başarılı olduğu response a set edilsin
            Helper.setErrorToResponse(Constant.ERRORCODE.SYS_SUCCESS, response);
            return(response);
        }
コード例 #15
0
        public List <QuestionType> getQuestionTypeAll()
        {
            QuestionProjeEntities db = new QuestionProjeEntities();

            return(db.QuestionType.ToList());
        }
コード例 #16
0
        public List <Language> getLanguageAll()
        {
            QuestionProjeEntities db = new QuestionProjeEntities();

            return(db.Language.ToList());
        }