InsertProjectContext() public method

public InsertProjectContext ( sp_Project_DM &_cProject ) : sp_Project_DM
_cProject VolTeer.DomainModels.VT.Vend.sp_Project_DM
return VolTeer.DomainModels.VT.Vend.sp_Project_DM
示例#1
0
        public void TestProjectCreate()
        {
            string ProjectName = "TestProject";
            string ProjectDesc = "We Rock!";
            bool ActiveFlg = true;
            var Project_bll = new sp_Project_BLL();
            var Project_dm = new sp_Project_DM();
            var VendAdress_bll = new sp_VendAddress_BLL();
            Project_dm.ProjectName = ProjectName;
            Project_dm.ProjectDesc = ProjectDesc;
            var allAddresses = VendAdress_bll.ListAddresses();
            Assert.IsTrue(allAddresses.Count > 0, "The ListAddresses() is broken, or no data in DB");
            Project_dm.AddrID = allAddresses[0].AddrID;
            Project_dm.ActiveFlg = ActiveFlg;
            var ProjectID = Project_bll.InsertProjectContext(ref Project_dm).ProjectID;
            Project_dm.ProjectID = ProjectID;

            var Project_dm_selected = Project_bll.ListProjects(ProjectID);
            Assert.IsTrue(Equals(Project_dm, Project_dm_selected));
        }
        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);
        }