public void addTransmissionToTransmissionSet(TransmissionSet set, Transmission value)
 {
     using (AcaIrsDbEntities db = new AcaIrsDbEntities())
     {
         db.Entry(set).State = EntityState.Modified;
         set.Transmissions.Add(value);
         db.Entry(value).State = EntityState.Added;
         db.SaveChanges();
     }
 }
        public void TestTransmissionSetCRUD()
        {
            ACATestDAL.DAL dal = new ACATestDAL.DAL();

            dal.deleteAllTransmissionSets();
            List<int> ids = dal.getTransmissionIDs("2015");
            Assert.AreEqual(0, ids.Count);

            // Create Transmission Set
            TransmissionSet set = new TransmissionSet();
            set.FiscalYear = "2015";
            dal.saveTransmissionSet(set);
            int id = set.TransmissionSetID;
            Assert.IsTrue(id > 0);
            Assert.AreEqual("2015", set.FiscalYear);

            // Add Transmission
            Transmission t1 = Transmission.buildTest();
            dal.addTransmissionToTransmissionSet(set, t1);

            ids = dal.getTransmissionIDs("2015");
            Assert.AreEqual(1, ids.Count);

            // Add 2nd Transmission Set
            Transmission t2 = Transmission.buildTest();
            dal.addTransmissionToTransmissionSet(set, t2);

            ids = dal.getTransmissionIDs("2015");
            Assert.AreEqual(2, ids.Count);

            System.DateTime d1 = new System.DateTime(2001, 7, 4, 0, 0, 0);
            t2.ImportDate = d1;
            dal.saveTransmission(t2);

            Transmission t3 = dal.getTransmissionByID(t2.TransmissionID);
            Assert.AreEqual(d1, t3.ImportDate);

            // Delete 1st Transmission
            dal.deleteTransmission(t1.TransmissionID);

            ids = dal.getTransmissionIDs("2015");
            Assert.AreEqual(1, ids.Count);

            dal.deleteAllTransmissionSets();

            ids = dal.getTransmissionIDs("2015");
            Assert.AreEqual(0, ids.Count);
        }
        public static TransmissionSet buildTest()
        {
            TransmissionSet set = new TransmissionSet();
            set.FiscalYear = "2015";

            for (int i = 0; i < 10; ++i)
            {
                Transmission t = Transmission.buildTest();
                //t.TransmissionSet = set;
                t.ImportDate = System.DateTime.Now;
                t.TransmissionDate = System.DateTime.Now;
                t.StatusReceived = System.DateTime.Now;
                set.Transmissions.Add(t);
            }
            return set;
        }
 public void saveTransmissionSet(TransmissionSet value)
 {
     using (AcaIrsDbEntities db = new AcaIrsDbEntities())
     {
         if (value.TransmissionSetID == default(int))
         {
             db.TransmissionSet.Add(value);
         }
         else
         {
             db.Entry(value).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
 }
 public void deleteTransmissionSet(TransmissionSet value)
 {
     using (AcaIrsDbEntities db = new AcaIrsDbEntities())
     {
         db.TransmissionSet.Remove(value);
         db.SaveChanges();
     }
 }