public void Test_UpdateMCQuestion()
        {
            MCQuestionDAO mcQuestion2 = new MCQuestionDAO() { ID = 2, MCQuestionID = 2, MCQuestionDescription = "NEWmcQ2" };

            Assert.IsTrue(MCQService.UpdateMCQuestion(mcQuestion2));
            Assert.AreEqual(MCQService.GetMCQuestionByID(2).MCQuestionDescription, "NEWmcQ2");
        }
        public void Test_CreateMCQuestion()
        {
            MCQuestionDAO mcQuestion3 = new MCQuestionDAO() { ID = 3, MCQuestionID = 3, MCQuestionDescription = "mcQ3" };

            Assert.IsTrue(MCQService.CreateMCQuestion(mcQuestion3));
            Assert.AreEqual(MCQService.GetMCQuestions().Count, 4);
        }
예제 #3
0
        internal void SetUp()
        {
            MCQuestionDAO mcQuestion0 = new MCQuestionDAO() { ID = 0, MCQuestionID = 0, MCQuestionDescription = "mcQ0" };
            MCQuestionDAO mcQuestion1 = new MCQuestionDAO() { ID = 1, MCQuestionID = 1, MCQuestionDescription = "mcQ1" };
            MCQuestionDAO mcQuestion2 = new MCQuestionDAO() { ID = 2, MCQuestionID = 2, MCQuestionDescription = "mcQ2" };

            MCQuestions.Add(mcQuestion0);
            MCQuestions.Add(mcQuestion1);
            MCQuestions.Add(mcQuestion2);
        }
예제 #4
0
 public bool UpdateMCQuestion(MCQuestionDAO newMCQuestion)
 {
     foreach(var mcQ in MCQuestions)
         if(mcQ.MCQuestionID == newMCQuestion.MCQuestionID)
         {
             MCQuestions.Remove(mcQ);
             MCQuestions.Add(newMCQuestion);
             return true;
         }
     return false;
 }
        public bool CreateMCQuestion(MCQuestionDAO s)
        {
            MCQuestion mCQuestion = new MCQuestion
            {
                MCQuestion_ID = s.MCQuestionID,
                MCQuestionDescription = s.MCQuestionDescription
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.MCQuestions.InsertOnSubmit(mCQuestion);

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
        public bool UpdateMCQuestion(MCQuestionDAO newMCQuestion)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                MCQuestion mCQuestion = db.MCQuestions.Single(s => s.MCQuestion_ID == newMCQuestion.MCQuestionID);
                mCQuestion.MCQuestion_ID = newMCQuestion.MCQuestionID;
                mCQuestion.MCQuestionDescription = newMCQuestion.MCQuestionDescription;

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
        public IList<MCQuestionDAO> GetMCQuestions()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<MCQuestion> mCQuestions = db.MCQuestions.ToList();
                    List<MCQuestionDAO> result = new List<MCQuestionDAO>();

                    foreach (var mCQuestion in mCQuestions)
                    {
                        MCQuestionDAO temp = new MCQuestionDAO
                        {
                            ID = mCQuestion.MCQuestion_ID,
                            MCQuestionID = mCQuestion.MCQuestion_ID,
                            MCQuestionDescription = mCQuestion.MCQuestionDescription
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public MCQuestionDAO GetMCQuestionByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             MCQuestion mCQuestion = (from mcqu in db.MCQuestions where mcqu.MCQuestion_ID == id select mcqu).FirstOrDefault();
             MCQuestionDAO result = new MCQuestionDAO
             {
                 ID = mCQuestion.MCQuestion_ID,
                 MCQuestionID = mCQuestion.MCQuestion_ID,
                 MCQuestionDescription = mCQuestion.MCQuestionDescription
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }
예제 #9
0
 private void Initialize( MCQuestionDAO mcQuestion, int id, int mcQuestionID, string mcQuestionDescription )
 {
     mcQuestion.ID = id;
     mcQuestion.MCQuestionID = mcQuestionID;
     mcQuestion.MCQuestionDescription = mcQuestionDescription;
 }
예제 #10
0
 public bool CreateMCQuestion(MCQuestionDAO e)
 {
     MCQuestions.Add(e);
     return true;
 }