예제 #1
0
        public Question Create(Question question)
        {
            EQuestion eQuestion = EQuestion(question);

            eQuestion = _iDQuestion.Create(eQuestion);
            return(Question(eQuestion));
        }
예제 #2
0
        public Question Create(int createdBy, Question question)
        {
            EQuestion eQuestion = EQuestion(question);

            eQuestion.CreatedDate = DateTime.Now;
            eQuestion.CreatedBy   = createdBy;
            eQuestion             = _iDQuestion.Create(eQuestion);
            return(Question(eQuestion));
        }
예제 #3
0
 public OQuestionTests()
 {
     _ctx   = ContextBuilder.Ctx;
     _sut   = new OQuestion(_ctx);
     _model = new EQuestion()
     {
         Text = "Thjis is question text"
     };
 }
        private Question Question(EQuestion eQuestion)
        {
            return(new Question
            {
                QuestionId = eQuestion.QuestionId,
                SurveyId = eQuestion.SurveyId,

                Description = eQuestion.Description
            });
        }
예제 #5
0
        private Question Question(EQuestion eQuestion)
        {
            Question returnQuestion = new Question
            {
                QuestionId  = eQuestion.QuestionId,
                Description = eQuestion.Description,
                Rate        = eQuestion.Rate,
            };

            return(returnQuestion);
        }
예제 #6
0
        private EQuestion EQuestion(Question question)
        {
            EQuestion returnEQuestion = new EQuestion
            {
                QuestionId  = question.QuestionId,
                Description = question.Description,
                Rate        = question.Rate,
            };

            return(returnEQuestion);
        }
예제 #7
0
 public static int AddQuestion(EQuestion obj)
 {
     using (var context = MasterDBContext())
     {
         return(context.StoredProcedure("dbo.AddQuestion")
                .Parameter("Text", obj.Text)
                .Parameter("CategoryName", obj.CategoryName)
                .Parameter("CategoryAnswer", obj.CategoryAnswer)
                .Execute());
     }
 }
예제 #8
0
        private Question Question(EQuestion eQuestion)
        {
            Question returnQuestion = new Question
            {
                ExamId     = eQuestion.ExamId,
                QuestionId = eQuestion.QuestionId,

                Description = eQuestion.Description
            };

            return(returnQuestion);
        }
예제 #9
0
        private EQuestion EQuestion(Question question)
        {
            EQuestion returnEQuestion = new EQuestion
            {
                ExamId     = question.ExamId,
                QuestionId = question.QuestionId,

                Description = question.Description
            };

            return(returnEQuestion);
        }
예제 #10
0
        public static void UpdateQuestion(EQuestion obj)
        {
            using (var context = MasterDBContext())
            {
                context.StoredProcedure("dbo.Question_Update")
                .Parameter("Id", obj.Id)
                .Parameter("Text", obj.Text)
                .Parameter("CategoryName", obj.CategoryName)
                .Parameter("ModifyDate", obj.ModifyDate)
                .Parameter("CategoryAnswer", obj.CategoryAnswer)

                .Execute();
            }
        }
예제 #11
0
 public int AddQuestion(List <Answer> Answer, EQuestion Qs)
 {
     if (Answer.Count == 0)
     {
         return(0);
     }
     if (Answer.Count > 1 && Qs.CategoryAnswer.ToUpper() == "Text".ToUpper())
     {
         return(0);
     }
     if (AdminContext.AddQuestion(Qs) < 0)
     {
         return(0);
     }
     return(AdminContext.AddAnswer(Answer));
 }
예제 #12
0
        public Question Read(int questionId)
        {
            EQuestion eQuestion = _iDQuestion.Read <EQuestion>(a => a.QuestionId == questionId);

            return(Question(eQuestion));
        }
예제 #13
0
 public ActionResult addQuestionFromExcel(HttpPostedFileBase file)
 {
     string[] name = file.FileName.Split('.');
     if (name[name.Length - 1] == "xlsx" ||
         name[name.Length - 1] == "xls")
     {
         string namefile = Path.GetFileName(file.FileName);
         string path     = Server.MapPath("/Content/File/" + namefile);
         file.SaveAs(path);
         Microsoft.Office.Interop.Excel.Application xlApp       = new Microsoft.Office.Interop.Excel.Application();
         Microsoft.Office.Interop.Excel.Workbook    xlWorkBook  = xlApp.Workbooks.Open(Path.Combine(Server.MapPath("~/Content/File"), namefile), 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);;
         Microsoft.Office.Interop.Excel.Worksheet   xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);;
         Microsoft.Office.Interop.Excel.Range       range       = xlWorkSheet.UsedRange;
         int rw = range.Rows.Count;
         int cl = range.Columns.Count;
         for (int row = 1; row <= rw; row++)
         {
             EQuestion question = new EQuestion();
             Object    TextQs   = (Object)(range.Cells[row, 1] as Microsoft.Office.Interop.Excel.Range).Value2;
             if (TextQs == null || TextQs.GetType() != ("").GetType())
             {
                 break;
             }
             Object TypeQs = (Object)(range.Cells[row, 3] as Microsoft.Office.Interop.Excel.Range).Value2;
             if (TypeQs == null || TypeQs.GetType() != ("").GetType())
             {
                 break;
             }
             Object CategoryAnswer = (Object)(range.Cells[row, 2] as Microsoft.Office.Interop.Excel.Range).Value2;
             if (CategoryAnswer == null || CategoryAnswer.GetType() != ("").GetType())
             {
                 break;
             }
             question.Text           = (string)TextQs;
             question.CategoryName   = (string)TypeQs;
             question.CategoryAnswer = (string)CategoryAnswer;
             List <Answer> answers = new List <Answer>();
             for (int col = 4; col <= cl; col += 2)
             {
                 Answer answer = new Answer();
                 Object textAs = (Object)(range.Cells[row, col] as Microsoft.Office.Interop.Excel.Range).Value2;
                 if (textAs == null || textAs.GetType() != ("").GetType())
                 {
                     break;
                 }
                 Object resultAs = (Object)(range.Cells[row, col + 1] as Microsoft.Office.Interop.Excel.Range).Value2;
                 if (resultAs == null || resultAs.GetType() != true.GetType())
                 {
                     break;
                 }
                 answer.TextAnswer = (String)textAs;
                 answer.result     = (bool)resultAs;
                 answers.Add(answer);
             }
             if (answers.Count <= 0)
             {
                 continue;
             }
             if (AdminContext.Search(question.Text) == true)
             {
                 continue;
             }
             AdminContext.AddQuestion(question);
             AdminContext.AddAnswer(answers);
         }
         xlWorkBook.Close();
     }
     return(RedirectToAction("Index"));
 }
예제 #14
0
 public IEnumerable UpdateQuestion(EQuestion obj)
 {
     AdminContext.UpdateQuestion(obj);
     return(JsonConvert.SerializeObject(obj));
 }