public Question Create(Question question) { EQuestion eQuestion = EQuestion(question); eQuestion = _iDQuestion.Create(eQuestion); return(Question(eQuestion)); }
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)); }
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 }); }
private Question Question(EQuestion eQuestion) { Question returnQuestion = new Question { QuestionId = eQuestion.QuestionId, Description = eQuestion.Description, Rate = eQuestion.Rate, }; return(returnQuestion); }
private EQuestion EQuestion(Question question) { EQuestion returnEQuestion = new EQuestion { QuestionId = question.QuestionId, Description = question.Description, Rate = question.Rate, }; return(returnEQuestion); }
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()); } }
private Question Question(EQuestion eQuestion) { Question returnQuestion = new Question { ExamId = eQuestion.ExamId, QuestionId = eQuestion.QuestionId, Description = eQuestion.Description }; return(returnQuestion); }
private EQuestion EQuestion(Question question) { EQuestion returnEQuestion = new EQuestion { ExamId = question.ExamId, QuestionId = question.QuestionId, Description = question.Description }; return(returnEQuestion); }
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(); } }
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)); }
public Question Read(int questionId) { EQuestion eQuestion = _iDQuestion.Read <EQuestion>(a => a.QuestionId == questionId); return(Question(eQuestion)); }
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")); }
public IEnumerable UpdateQuestion(EQuestion obj) { AdminContext.UpdateQuestion(obj); return(JsonConvert.SerializeObject(obj)); }