public string addQuestionvalues(DbExam value) { DbExam data = new DbExam(); int Seq; try { Seq = Context.DbExam.Where(i => i.ExamType == value.ExamType).Max(i => i.Seq) + 1; } catch { Seq = 1; } data.Seq = Seq; data.ExamType = value.ExamType; data.QuestionType = value.QuestionType; data.Question = value.Question; data.QuestionImage = value.QuestionImage; data.CorrectAnswer = value.CorrectAnswer; data.ChoiceType = value.ChoiceType; data.Choice1 = value.Choice1; data.Choice2 = value.Choice2; data.Choice3 = value.Choice3; data.Choice4 = value.Choice4; data.Choice5 = value.Choice5; data.Choice6 = value.Choice6; data.Active = value.Active; Context.DbExam.Add(data); Context.SaveChanges(); return("success"); }
public ArrayList StageExam_GetAll() { ArrayList lst = new ArrayList(); using (SqlConnection conn = getConnect()) { //SqlCommand cmd = new SqlCommand("select * " + // "from dethi, kyThi, monHoc " + // "where dethi.makythi = kyThi.makythi " + // "and dethi.mamon = monHoc.mamon", conn); SqlCommand cmd = new SqlCommand("select * from kyThi", conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { DbExam obj = new DbExam(); obj.stageExamAll_IDataReader(dr); lst.Add(obj); } } } return(lst); }
public IActionResult editQuestionvalues(DbExam value) { try { string result = IExam.editQuestionvalues(value); return(Ok(result)); } catch (Exception e) { return(Ok()); } }
public IActionResult addQuestionvalues(DbExam value) { try { string result = IExam.addQuestionvalues(value); return(Ok(result)); } catch (Exception e) { return(Ok(e.InnerException.Message)); } }
public string deleteQuetionvalues(string examType, string questionType, string question) { DbExam data = new DbExam(); data = Context.DbExam.Where(x => x.ExamType == examType && x.QuestionType == questionType && x.Question == question).FirstOrDefault(); Context.DbExam.Remove(data); Context.SaveChanges(); return("success"); }
public ArrayList getExamDetailById(string id) { ArrayList lst = new ArrayList(); using (SqlConnection conn = getConnect()) { SqlCommand cmd = new SqlCommand("select * from ctdethi where madethi= '" + id + "'", conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { DbExam obj = new DbExam(); obj.detailExam_IDataReader(dr); lst.Add(obj); } } } return(lst); }
public string editQuestionvalues(DbExam value) { DbExam editQuestion = Context.DbExam.Where(x => x.ExamType == value.ExamType && x.Seq == value.Seq).FirstOrDefault(); editQuestion.ExamType = value.ExamType; editQuestion.QuestionType = value.QuestionType; editQuestion.Question = value.Question; editQuestion.QuestionImage = value.QuestionImage; editQuestion.CorrectAnswer = value.CorrectAnswer; editQuestion.ChoiceType = value.ChoiceType; editQuestion.Choice1 = value.Choice1; editQuestion.Choice2 = value.Choice2; editQuestion.Choice3 = value.Choice3; editQuestion.Choice4 = value.Choice4; editQuestion.Choice5 = value.Choice5; editQuestion.Choice6 = value.Choice6; editQuestion.Active = value.Active; Context.DbExam.Update(editQuestion); Context.SaveChanges(); return("success"); }