public void AddContactTest()
 {
     //int AddContact(int moduleId, int itemId, String userName, String name, String role, String email,
     //           String contact1, String contact2)
     DesktopModulesFacade facade = new DesktopModulesFacade();
     PortalContact contact = new PortalContact();
     contact.ModuleID=0;
     contact.ItemID=0;
     contact.CreatedByUser="******";
     contact.Name="n";
     contact.Role="r";
     contact.Email="e";
     contact.Contact1="c1";
     contact.Contact2="c2";
     facade.AddContact(contact);
 }
        public int AddContact(PortalContact contact)
        {
            // TODO: add access security here..
            // TODO: add argument validation here..

            int retval;
            // Run within the context of a database transaction.
            // The Decorator Design Pattern.
            using (TransactionDecorator transaction = new TransactionDecorator())
            {
                retval = contactsDAO.AddContact(contact.ModuleID, contact.ItemID, contact.CreatedByUser,
                                                contact.Name, contact.Role, contact.Email,
                                                contact.Contact1, contact.Contact2);
                transaction.Complete();
            }
            return retval;
        }
예제 #3
0
        //****************************************************************
        //
        // The UpdateBtn_Click event handler on this Page is used to either
        // create or update a contact.  It  uses the Nairc.KPWPortal.ContactsDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************
        protected void UpdateBtn_Click(Object sender, EventArgs e)
        {
            // Only Update if Entered data is Valid
            if (Page.IsValid == true)
            {
                IDesktopModulesFacade facade = new DesktopModulesFacade();
                PortalContact contact = new PortalContact();
                contact.ModuleID =moduleId;
                contact.ItemID =itemId;
                contact.CreatedByUser =Context.User.Identity.Name;
                contact.Name =NameField.Text;
                contact.Role =RoleField.Text;
                contact.Email =EmailField.Text;
                contact.Contact1 = Contact1Field.Text;
                contact.Contact2 = Contact2Field.Text;

                if (itemId == 0)
                {
                    // Add the contact within the contacts table
                    facade.AddContact(contact);
                }
                else
                {
                    // Update the contact within the contacts table
                    facade.UpdateContact(contact);
                }

                // Redirect back to the portal home page
                Response.Redirect((String) ViewState["UrlReferrer"]);
            }
        }