Beispiel #1
0
        public void Test_UpdateMCOption()
        {
            MCOptionDAO mcOpt3 = new MCOptionDAO() { ID = 3, MCOptionID = 0, MCOptionDescription = "Description 3" };

            Assert.IsTrue(mcoService.UpdateMCOption(mcOpt3));
            Assert.AreEqual(mcoService.GetMCOptionByID(0).ID, 3);
        }
Beispiel #2
0
        public void Test_CreateMCOption()
        {
            MCOptionDAO mcOpt3 = new MCOptionDAO() { ID = 3, MCOptionID = 3, MCOptionDescription = "Description 3" };

            Assert.IsTrue(mcoService.CreateMCOption(mcOpt3));
            Assert.AreEqual(mcoService.GetMCOptions().Count, 4);
        }
        internal void SetUp()
        {
            MCOptionDAO mcOpt0 = new MCOptionDAO() { ID = 0, MCOptionID = 0, MCOptionDescription = "Description 0" };
            MCOptionDAO mcOpt1 = new MCOptionDAO() { ID = 1, MCOptionID = 1, MCOptionDescription = "Description 1" };
            MCOptionDAO mcOpt2 = new MCOptionDAO() { ID = 2, MCOptionID = 2, MCOptionDescription = "Description 2" };

            MCOptions.Add(mcOpt0);
            MCOptions.Add(mcOpt1);
            MCOptions.Add(mcOpt2);
        }
 public bool UpdateMCOption(MCOptionDAO newMCOption)
 {
     foreach (var mcoption in MCOptions)
         if (mcoption.MCOptionID == newMCOption.MCOptionID)
         {
             MCOptions.Remove(mcoption);
             MCOptions.Add(newMCOption);
             return true;
         }
     return false;
 }
 private void Initialize( MCOptionDAO mcOption, int id, int mcOptionID, string mcOptionDescription )
 {
     mcOption.ID = id;
     mcOption.MCOptionID = mcOptionID;
     mcOption.MCOptionDescription = mcOptionDescription;
 }
 public bool CreateMCOption(MCOptionDAO e)
 {
     MCOptions.Add(e);
     return true;
 }
        public bool CreateMCOption(MCOptionDAO s)
        {
            MCOption mCOption = new MCOption
            {
                MCOption_ID = s.MCOptionID,
                MCOptionDescription = s.MCOptionDescription
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.MCOptions.InsertOnSubmit(mCOption);

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

            return true;
        }
        public bool UpdateMCOption(MCOptionDAO newMCOption)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                MCOption mCOption = db.MCOptions.Single(s => s.MCOption_ID == newMCOption.MCOptionID);
                mCOption.MCOption_ID = newMCOption.MCOptionID;
                mCOption.MCOptionDescription = newMCOption.MCOptionDescription;

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

            return true;
        }
        public IList<MCOptionDAO> GetMCOptions()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<MCOption> mCOptions = db.MCOptions.ToList();
                    List<MCOptionDAO> result = new List<MCOptionDAO>();

                    foreach (var mCOption in mCOptions)
                    {
                        MCOptionDAO temp = new MCOptionDAO
                        {
                            ID = mCOption.MCOption_ID,
                            MCOptionID = mCOption.MCOption_ID,
                            MCOptionDescription = mCOption.MCOptionDescription
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public MCOptionDAO GetMCOptionByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             MCOption mCOption = (from mcopt in db.MCOptions where mcopt.MCOption_ID == id select mcopt).FirstOrDefault();
             MCOptionDAO result = new MCOptionDAO
             {
                 ID = mCOption.MCOption_ID,
                 MCOptionID = mCOption.MCOption_ID,
                 MCOptionDescription = mCOption.MCOptionDescription
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }