Exemplo n.º 1
0
        public QuestionListResponse GetQuestionsForSet([FromUri] string setName)
        {
            ModuleBuilderManager m        = new ModuleBuilderManager();
            QuestionListResponse response = m.GetQuestionsForSet(setName);

            return(response);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public async Task <QuestionListResponse> GetQuestionsByYearAsync(int year)
        {
            QuestionListResponse response = new QuestionListResponse();

            try
            {
                var questionAccessor = new QuestionAccessor(_dbContext);

                response.Data = await questionAccessor.GetQuestionsByYearAsync(year);

                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public QuestionListResponse deleteQuestion(int ID)
        {
            QuestionListResponse  response = new QuestionListResponse();
            QuestionProjeEntities db       = new QuestionProjeEntities();

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                Question question = db.Question.Where(r => r.ID == ID).SingleOrDefault();
                question.State = false;
                db.SaveChanges();
                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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }