public void Test_UpdateQuestionBank() { QuestionBankDAO questionBank2 = new QuestionBankDAO() { ID = 2, QuestionBankID = 2, MCQuestionID = 2, MCOptionID = 4 }; Assert.IsTrue(QBService.UpdateQuestionBank(questionBank2)); Assert.AreEqual(QBService.GetQuestionBankByID(2).MCOptionID, 4); }
private void Initialize( QuestionBankDAO QuestionBank, int id, int questionBankID, int mcQuestionID, int mcOptionID ) { QuestionBank.ID = id; QuestionBank.QuestionBankID = questionBankID; QuestionBank.MCQuestionID = mcQuestionID; QuestionBank.MCOptionID = mcOptionID; }
public void Test_CreateQuestionBank() { QuestionBankDAO questionBank3 = new QuestionBankDAO() { ID = 3, QuestionBankID = 3, MCQuestionID = 3, MCOptionID = 3 }; Assert.IsTrue(QBService.CreateQuestionBank(questionBank3)); Assert.AreEqual(QBService.GetQuestionBanks().Count, 4); }
internal void SetUp() { QuestionBankDAO questionBank0 = new QuestionBankDAO() { ID = 0, QuestionBankID = 0, MCQuestionID = 0, MCOptionID = 0 }; QuestionBankDAO questionBank1 = new QuestionBankDAO() { ID = 1, QuestionBankID = 1, MCQuestionID = 1, MCOptionID = 1 }; QuestionBankDAO questionBank2 = new QuestionBankDAO() { ID = 2, QuestionBankID = 2, MCQuestionID = 2, MCOptionID = 2 }; QuestionBanks.Add(questionBank0); QuestionBanks.Add(questionBank1); QuestionBanks.Add(questionBank2); }
public bool UpdateQuestionBank(QuestionBankDAO newQuestionBank) { foreach(var qb in QuestionBanks) if(qb.QuestionBankID == newQuestionBank.QuestionBankID) { QuestionBanks.Remove(qb); QuestionBanks.Add(newQuestionBank); return true; } return false; }
public bool CreateQuestionBank(QuestionBankDAO e) { QuestionBanks.Add(e); return true; }
public bool CreateQuestionBank(QuestionBankDAO s) { QuestionBank questionBank = new QuestionBank { QuestionBank_ID = s.QuestionBankID, MCQuestion_ID = s.MCQuestionID, MCOption_ID = s.MCOptionID, MCCorrectOption = s.MCCorrectOption }; using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { db.QuestionBanks.InsertOnSubmit(questionBank); try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public bool UpdateQuestionBank(QuestionBankDAO newQuestionBank) { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { QuestionBank questionBank = db.QuestionBanks.Single(s => s.QuestionBank_ID == newQuestionBank.QuestionBankID); questionBank.QuestionBank_ID = newQuestionBank.QuestionBankID; questionBank.MCQuestion_ID = newQuestionBank.MCQuestionID; questionBank.MCOption_ID = newQuestionBank.MCOptionID; questionBank.MCCorrectOption = newQuestionBank.MCCorrectOption; try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public IList<QuestionBankDAO> GetQuestionBanks() { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { IList<QuestionBank> questionBanks = db.QuestionBanks.ToList(); List<QuestionBankDAO> result = new List<QuestionBankDAO>(); foreach (var questionBank in questionBanks) { QuestionBankDAO temp = new QuestionBankDAO { ID = questionBank.QuestionBank_ID, QuestionBankID = questionBank.QuestionBank_ID, MCQuestionID = questionBank.MCQuestion_ID, MCOptionID = questionBank.MCOption_ID, MCCorrectOption = questionBank.MCCorrectOption }; result.Add(temp); } return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }
public QuestionBankDAO GetQuestionBankByMCQuestionIDAndMCOptionID(int MCQuestionID, int MCOptionID) { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { QuestionBank questionBank = (from qubk in db.QuestionBanks where qubk.MCQuestion_ID == MCQuestionID && qubk.MCOption_ID == MCOptionID select qubk).FirstOrDefault(); QuestionBankDAO result = new QuestionBankDAO { ID = questionBank.QuestionBank_ID, QuestionBankID = questionBank.QuestionBank_ID, MCQuestionID = questionBank.MCQuestion_ID, MCOptionID = questionBank.MCOption_ID, MCCorrectOption = questionBank.MCCorrectOption }; return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }