public void DeleteContactContext(sp_VendorProjContact_DM InputContact)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var VendorProjContactsToRemove = (from n in context.tblVendorProjContacts where n.VendorID == InputContact.VendorID
                                               && n.ProjectID == InputContact.ProjectID
                                               && n.ContactID == InputContact.ContactID select n).FirstOrDefault();
         context.tblVendorProjContacts.Remove(VendorProjContactsToRemove);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void TestVendorProjContactInsert()
 {
     //Test Our Read
     sp_VendorProjContact_DM data = new sp_VendorProjContact_DM();
     data.VendorID = new Guid();
     bool insertPrimaryContact = true;
     data.PrimaryContact = insertPrimaryContact;
     sp_VendorProjContact_BLL contact = new sp_VendorProjContact_BLL();
     contact.InsertContactContext(data);
     Assert.AreEqual(insertPrimaryContact, data.PrimaryContact, "Primary Contact Not Set As Expected");
 }
 public Guid InsertContactContext(sp_VendorProjContact_DM InputContact)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var NewContact = new tblVendorProjContact
         {
             VendorID = InputContact.VendorID,
             ProjectID = InputContact.ProjectID,
             ContactID = InputContact.ContactID,
             PrimaryContact = InputContact.PrimaryContact
         };
         context.tblVendorProjContacts.Add(NewContact);
         context.SaveChanges();
         //Return the id of the newly created record
         return NewContact.ContactID;
     }
 }
Exemplo n.º 4
0
 public void TestVendorProjContactDelete()
 {
     DataTable dt = cExcel.ReadExcelFile("Sheet1", Path.Combine(cExcel.GetHelperFilesDir(), "tblVendorProjContact.xlsx"));
     foreach (DataRow row in dt.Rows) // Loop over the rows.
     {
         Guid VendorID = new Guid(row["VendorID"].ToString());
         Guid ProjectID = new Guid(row["ProjectID"].ToString());
         Guid ContactID = new Guid(row["ContactID"].ToString());
         sp_VendorProjContact_DM data = new sp_VendorProjContact_DM();
         sp_VendorProjContact_BLL vend = new sp_VendorProjContact_BLL();
         data.VendorID = VendorID;
         data.ProjectID = ProjectID;
         data.ContactID = ContactID;
         vend.DeleteContactContext(data);
         data = vend.ListContact(VendorID, ProjectID, ContactID);
         Assert.AreEqual(false, data.PrimaryContact, "PrimaryContact not set as expected");
     }
 }
        public void UpdateContactContext(sp_VendorProjContact_DM InputContact)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var existingContact = context.tblVendorProjContacts.Find(InputContact.VendorID,
                                                                         InputContact.ProjectID,
                                                                         InputContact.ContactID,
                                                                         InputContact.PrimaryContact);

                if (InputContact != null)
                {
                    existingContact.VendorID = InputContact.VendorID;
                    existingContact.ProjectID = InputContact.ProjectID;
                    existingContact.ContactID = InputContact.ContactID;
                    existingContact.PrimaryContact = InputContact.PrimaryContact;
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 6
0
        public void TestVendorProjContactUpdate()
        {
            //Test Our Read
            DataTable dt = cExcel.ReadExcelFile("Sheet1", Path.Combine(cExcel.GetHelperFilesDir(), "tblVendorProjContact.xlsx"));
            foreach (DataRow row in dt.Rows) // Loop over the rows.
            {
                bool updatePrimaryContact = Convert.ToBoolean(row["PrimaryContact"]);
                string contactID = row["ContactID"].ToString();
                string vendorID = row["VendorID"].ToString();
                string projectID = row["ProjectID"].ToString();
                sp_VendorProjContact_DM data = new sp_VendorProjContact_DM();
                data.ContactID = new Guid(contactID);
                data.PrimaryContact = updatePrimaryContact;
                sp_VendorProjContact_BLL VendorProjContact = new sp_VendorProjContact_BLL();
                VendorProjContact.UpdateContactContext(data);
                data = VendorProjContact.ListContact(new Guid(vendorID), new Guid(projectID), new Guid(contactID));
                Assert.AreEqual(updatePrimaryContact, data.PrimaryContact, "Primary Contact Not Set As Expected");

            }
        }
 public void UpdateContactContext(sp_VendorProjContact_DM InputContact)
 {
     DAL.UpdateContactContext(InputContact);
 }
 public Guid InsertContactContext(sp_VendorProjContact_DM InputContact)
 {
     return DAL.InsertContactContext(InputContact);
 }
 public void DeleteContactContext(sp_VendorProjContact_DM InputContact)
 {
     DAL.DeleteContactContext(InputContact);
 }
        protected void saveForm()
        {
            sp_Project_DM projectDM = new sp_Project_DM();
            sp_VendorProjContact_DM vpContactDM = new sp_VendorProjContact_DM();

            vpContactDM.VendorID = (Guid)currentUser.ProviderUserKey;
            Guid projectID = Guid.NewGuid();

            vpContactDM.ProjectID = projectID;

            int contectIndex = rCBContact.SelectedIndex;
            if (rCBContact.SelectedIndex != 0)
            {
                vpContactDM.ContactID = contacts.ElementAt(rCBContact.SelectedIndex - 1).ContactID;

                //we can't set a contact as primary if there isn't a contact selected
                vpContactDM.PrimaryContact = cbPrimaryContact.Checked;
            }

            if (rCBAddress.SelectedIndex != 0)
            {
                projectDM.AddrID = addresses.ElementAt(rCBAddress.SelectedIndex - 1).AddrID;
            }
            projectDM.ProjectID = projectID;
            projectDM.ProjectName = rTBProjName.Text;
            projectDM.ProjectDesc = rTBProjDesc.Text;
            projectDM.ActiveFlg = false;

            sp_Project_BLL projectBLL = new sp_Project_BLL();
            sp_VendorProjContact_BLL vpContactBLL = new sp_VendorProjContact_BLL();

            //Why is it by ref? That's weird.
            projectBLL.InsertProjectContext(ref projectDM);
            vpContactBLL.InsertContactContext(vpContactDM);
        }