public void Test_UpdateSAQuestion()
        {
            SAQuestionDAO saQuest2 = new SAQuestionDAO() { ID = 2, SAQuestionID = 2, SAQuestionDescription = "TestDesc2" };

            Assert.IsTrue(SAQService.UpdateSAQuestion(saQuest2));
            Assert.AreEqual(SAQService.GetSAQuestionByID(2).SAQuestionDescription, "TestDesc2");
        }
        public void Test_CreateSAQuestion()
        {
            SAQuestionDAO saQuest3 = new SAQuestionDAO() { ID = 3, SAQuestionID = 3, SAQuestionDescription = "Desc3" };

            Assert.IsTrue(SAQService.CreateSAQuestion(saQuest3));
            Assert.AreEqual(SAQService.GetSAQuestions().Count, 4);
        }
        internal void SetUp()
        {
            SAQuestionDAO saQuest0 = new SAQuestionDAO() { ID = 0, SAQuestionID = 0, SAQuestionDescription = "Desc0" };
            SAQuestionDAO saQuest1 = new SAQuestionDAO() { ID = 1, SAQuestionID = 1, SAQuestionDescription = "Desc1" };
            SAQuestionDAO saQuest2 = new SAQuestionDAO() { ID = 2, SAQuestionID = 2, SAQuestionDescription = "Desc2" };

            SAQuestions.Add(saQuest0);
            SAQuestions.Add(saQuest1);
            SAQuestions.Add(saQuest2);
        }
 public bool UpdateSAQuestion(SAQuestionDAO newSAQuestion)
 {
     foreach (var value in SAQuestions)
         if (value.SAQuestionID == newSAQuestion.SAQuestionID)
         {
             SAQuestions.Remove(value);
             SAQuestions.Add(newSAQuestion);
             return true;
         }
     return false;
 }
 private void Initialize( SAQuestionDAO SAQuestion, int id, int saQuestionID, string saQuestionDesc )
 {
     SAQuestion.ID = id;
     SAQuestion.SAQuestionID = saQuestionID;
     SAQuestion.SAQuestionDescription = saQuestionDesc;
 }
 public bool CreateSAQuestion(SAQuestionDAO e)
 {
     SAQuestions.Add(e);
     return true;
 }
        public bool CreateSAQuestion(SAQuestionDAO s)
        {
            SAQuestion sAQuestion = new SAQuestion
            {
                SAQuestion_ID = s.SAQuestionID,
                SAQuestionDescription = s.SAQuestionDescription
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.SAQuestions.InsertOnSubmit(sAQuestion);

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

            return true;
        }
        public bool UpdateSAQuestion(SAQuestionDAO newSAQuestion)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                SAQuestion sAQuestion = db.SAQuestions.Single(s => s.SAQuestion_ID == newSAQuestion.SAQuestionID);
                sAQuestion.SAQuestion_ID = newSAQuestion.SAQuestionID;
                sAQuestion.SAQuestionDescription = newSAQuestion.SAQuestionDescription;

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

            return true;
        }
        public IList<SAQuestionDAO> GetSAQuestions()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<SAQuestion> sAQuestions = db.SAQuestions.ToList();
                    List<SAQuestionDAO> result = new List<SAQuestionDAO>();

                    foreach (var sAQuestion in sAQuestions)
                    {
                        SAQuestionDAO temp = new SAQuestionDAO
                        {
                            ID = sAQuestion.SAQuestion_ID,
                            SAQuestionID = sAQuestion.SAQuestion_ID,
                            SAQuestionDescription = sAQuestion.SAQuestionDescription
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public SAQuestionDAO GetSAQuestionByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             SAQuestion sAQuestion = (from saqu in db.SAQuestions where saqu.SAQuestion_ID == id select saqu).FirstOrDefault();
             SAQuestionDAO result = new SAQuestionDAO
             {
                 ID = sAQuestion.SAQuestion_ID,
                 SAQuestionID = sAQuestion.SAQuestion_ID,
                 SAQuestionDescription = sAQuestion.SAQuestionDescription
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }