private void SaveContact()
        {
            contactManager = new ContactManager(this);
            contact = new DataClasses.Contact();
            var originalContact = new DataClasses.Contact();

            if (!String.IsNullOrEmpty(Request["ContactId"]))
            {
                originalContact = contactManager.GetContact(Convert.ToInt32(Request["ContactId"]));
                contact.CopyPropertiesFrom(originalContact);
            }
            else contact.UserId = User.Identity.UserId;

            contact.CompanyId = Company.CompanyId;
            contact.AddressComp = ucAddress.AddressComp;
            contact.AddressNumber = ucAddress.AddressNumber;
            contact.PostalCode = ucAddress.PostalCode;

            contact.CellPhone = txtCellPhone.Text;
            contact.Email = txtMail.Text;
            contact.Msn = txtMsn.Text;
            contact.Name = txtName.Text;
            contact.Observation = txtObservation.Text;
            contact.Phone = txtPhone.Text;
            contact.Phone2 = txtPhone2.Text;
            contact.Sector = txtSector.Text;
            contact.Skype = txtSkype.Text;


            if (!String.IsNullOrEmpty(Request["ContactId"]))
                contactManager.Update(originalContact, contact);
            else
            {
                contactManager.Insert(contact);

                if (Session["CustomerId"] != null)
                {
                    var customerContact = new CustomerContact();
                    customerContact.CompanyId = Company.CompanyId;
                    customerContact.CustomerId = Convert.ToInt32(Session["CustomerId"].ToString());
                    customerContact.ContactId = contact.ContactId;
                    contactManager.InsertCustomerContact(customerContact);
                }
                else
                {
                    var supplierContact = new SupplierContact();
                    supplierContact.CompanyId = Company.CompanyId;
                    supplierContact.SupplierId = Convert.ToInt32(Session["SupplierId"].ToString());
                    supplierContact.ContactId = contact.ContactId;
                    contactManager.InsertSupplierContact(supplierContact);
                }
            }
        }
        public void AddContact(Contact entity, Int32 companyId, Int32 customerId)
        {
            var contactManager = new ContactManager(this);
            entity.CompanyId = companyId;
            contactManager.Insert(entity);

            var ccManager = new CustomerContactManager(this);
            var cc = new CustomerContact();
            cc.CustomerId = customerId;
            cc.ContactId = entity.ContactId;
            cc.CompanyId = companyId;
            ccManager.Insert(cc);
        }
Example #3
0
        /// <summary>
        /// Basic Insert Method
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="companyId"></param>
        /// <param name="supplierId"></param>
        public void AddContact(Contact entity, Int32 companyId, Int32 supplierId)
        {
            var contactManager = new ContactManager(this);

            entity.CompanyId = companyId;
            contactManager.Insert(entity);

            var scManager = new SuppliersContactManager(this);
            var sc        = new SupplierContact();

            sc.SupplierId = supplierId;
            sc.ContactId  = entity.ContactId;
            sc.CompanyId  = companyId;
            scManager.Insert(sc);
        }
        /// <summary>
        /// this method add the administrator of new company as contact of host'customer
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="userId"></param>
        private void AddContactInHostCustomer(Int32 customerId, Int32 userId)
        {
            var contactManager = new ContactManager(this);
            var customerContactManager = new CustomerContactManager(this);
            var profileManager = new ProfileManager(this);
            Profile profile = profileManager.GetProfileByUser(userId);
            var contact = new Contact
                              {
                                  Name = profile.Name,
                                  Phone = profile.Phone,
                                  CellPhone = profile.CellPhone,
                                  Address = profile.Address,
                                  AddressComp = profile.AddressComp,
                                  AddressNumber = profile.AddressNumber,
                                  Email = profile.Email,
                                  PostalCode = profile.PostalCode
                              };

            contactManager.Insert(contact);

            var customerContact = new CustomerContact();
            customerContact.CompanyId = GetHostCompany().CompanyId;
            customerContact.ContactId = contact.ContactId;
            customerContact.CustomerId = customerId;
            customerContactManager.Insert(customerContact);
        }
        /// <summary>
        /// Basic Insert Method
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="companyId"></param>
        /// <param name="supplierId"></param>
        public void AddContact(Contact entity, Int32 companyId, Int32 supplierId)
        {
            var contactManager = new ContactManager(this);
            entity.CompanyId = companyId;
            contactManager.Insert(entity);

            var scManager = new SuppliersContactManager(this);
            var sc = new SupplierContact();
            sc.SupplierId = supplierId;
            sc.ContactId = entity.ContactId;
            sc.CompanyId = companyId;
            scManager.Insert(sc);
        }