Ejemplo n.º 1
0
        private PeopleModels.NewContact GetDataForVendor(Intuit.Ipp.Data.Vendor Model, int typeid)
        {
            int siteCoID  = siteusercompanyid;
            var coContact = new PeopleModels.NewContact();

            coContact.ContactID = 0;
            coContact.First     = Model.GivenName;
            coContact.Last      = Model.FamilyName;
            coContact.Company   = Model.CompanyName;
            if (Model.PrimaryPhone != null)
            {
                coContact.Phone  = Model.PrimaryPhone.FreeFormNumber;
                coContact.Mobile = Model.PrimaryPhone.FreeFormNumber;
            }
            if (Model.PrimaryEmailAddr != null)
            {
                coContact.Email = Model.PrimaryEmailAddr.Address;
            }
            if (Model.BillAddr != null)
            {
                coContact.Address1 = Model.BillAddr.Line1;
                coContact.Address2 = Model.BillAddr.Line2;
                coContact.City     = Model.BillAddr.City;
                coContact.Zip      = Model.BillAddr.PostalCode;
            }
            coContact.State     = "";
            coContact.CountryID = 0;
            coContact.TypeID    = typeid;
            coContact.StatusID  = (int?)Model.status;
            coContact.OwnerID   = 0;


            return(coContact);
        }
        private PeopleModels.NewContact GetDataForVendor(Intuit.Ipp.Data.Vendor Model, int typeid)
        {
            int siteCoID  = siteusercompanyid;
            var coContact = new PeopleModels.NewContact()
            {
                ContactID = 0,
                First     = Model.GivenName,
                Last      = Model.FamilyName,
                Company   = Model.CompanyName,
                Phone     = Model.PrimaryPhone.FreeFormNumber,
                Mobile    = Model.PrimaryPhone.FreeFormNumber,
                Email     = Model.PrimaryEmailAddr.Address,
                Address1  = Model.BillAddr.Line1,
                Address2  = Model.BillAddr.Line2,
                City      = Model.BillAddr.City,
                State     = "",
                Zip       = Model.BillAddr.PostalCode,
                CountryID = 0,
                TypeID    = typeid,
                StatusID  = (int?)Model.status,
                OwnerID   = 0
            };

            return(coContact);
        }
Ejemplo n.º 3
0
 private string SyncSingleCustomer(string type, int contactID)
 {
     if (type.ToUpper() == "CUSTOMER")
     {
         List <Intuit.Ipp.Data.Customer> custList = new List <Intuit.Ipp.Data.Customer>();
         var coContacts = db.GetQbCustomersBySiteCoID(siteusercompanyid).Where(x => x.ViewID == contactID).ToList();
         foreach (var cust in coContacts)
         {
             Intuit.Ipp.Data.Customer qboCust = new Intuit.Ipp.Data.Customer();
             qboCust.SyncToken = "1";
             if (cust.Id != null && cust.Id != "")
             {
                 qboCust.Id = cust.Id.ToString();
             }
             qboCust.GivenName = cust.GivenName;
             if (cust.FamilyName != null && cust.FamilyName != "")
             {
                 qboCust.FamilyName = cust.FamilyName;
             }
             if (cust.DisplayName != null && cust.DisplayName != "")
             {
                 qboCust.DisplayName = cust.DisplayName;
             }
             if (cust.CompanyName != null && cust.CompanyName != "")
             {
                 if (cust.CompanyName.Contains("'"))
                 {
                     cust.CompanyName = cust.CompanyName.Replace("'", "\'");
                 }
                 qboCust.CompanyName = cust.CompanyName;
             }
             if (cust.PrimaryPhone != null && cust.PrimaryPhone != "")
             {
                 qboCust.PrimaryPhone = new Intuit.Ipp.Data.TelephoneNumber {
                     FreeFormNumber = cust.PrimaryPhone.ToString()
                 }
             }
             ;
             if (cust.Mobile != null && cust.Mobile != "")
             {
                 qboCust.Mobile = new Intuit.Ipp.Data.TelephoneNumber {
                     FreeFormNumber = cust.Mobile.ToString()
                 }
             }
             ;
             if (cust.PrimaryEmailAddr != null && cust.PrimaryEmailAddr != "")
             {
                 qboCust.PrimaryEmailAddr = new Intuit.Ipp.Data.EmailAddress {
                     Address = cust.PrimaryEmailAddr.ToString()
                 }
             }
             ;
             qboCust.BillAddr = new Intuit.Ipp.Data.PhysicalAddress();
             if (cust.BillAddrId != 0)
             {
                 qboCust.BillAddr.Id = Convert.ToString(cust.BillAddrId);
             }
             if (cust.BillAddrLine1 != null && cust.BillAddrLine1 != "")
             {
                 qboCust.BillAddr.Line1 = cust.BillAddrLine1;
             }
             if (cust.BillAddrLine2 != null && cust.BillAddrLine2 != "")
             {
                 qboCust.BillAddr.Line2 = cust.BillAddrLine2;
             }
             if (cust.BillAddrCity != null && cust.BillAddrCity != "")
             {
                 qboCust.BillAddr.City = cust.BillAddrCity;
             }
             if (cust.BillAddrCountry != null && cust.BillAddrCountry != "")
             {
                 qboCust.BillAddr.Country = cust.BillAddrCountry;
             }
             if (cust.BillAddrCountrySubDivisionCode != null && cust.BillAddrCountrySubDivisionCode != "")
             {
                 qboCust.BillAddr.CountrySubDivisionCode = cust.BillAddrCountrySubDivisionCode;
             }
             if (cust.BillAddrPostalCode != null && cust.BillAddrPostalCode != "")
             {
                 qboCust.BillAddr.PostalCode = cust.BillAddrPostalCode;
             }
             if (cust.BillAddrLine1 != null && cust.BillAddrLine1 != "")
             {
                 qboCust.BillAddr.Line1 = cust.BillAddrLine1;
             }
             custList.Add(qboCust);
         }
         QBAuthorizationdto oAuthDetails = new QBOAuthService(new QBAuthorizationdto()).GetAccessToken(this);
         syncService              = new QBSyncService(oAuthDetails);
         syncObjects              = new QBSyncdto();
         syncObjects.OauthToken   = oAuthDetails;
         syncObjects.CompanyId    = oAuthDetails.Realmid;
         syncObjects.CustomerList = custList;
         if (syncObjects.CustomerList.Count > 0)
         {
             syncObjects = syncService.SyncCustomer(this, syncObjects);
         }
     }
     else if (type.ToUpper() == "VENDOR")
     {
         List <Intuit.Ipp.Data.Vendor> vendorList = new List <Intuit.Ipp.Data.Vendor>();
         var vendor = db.GetQbVendorsBySiteCoID(siteusercompanyid).Where(p => p.ViewID == contactID).FirstOrDefault();
         if (vendor != null)
         {
             Intuit.Ipp.Data.Vendor qboVendor = new Intuit.Ipp.Data.Vendor();
             qboVendor.SyncToken = "1";
             qboVendor.GivenName = vendor.GivenName;
             if (vendor.FamilyName != null && vendor.FamilyName != "")
             {
                 qboVendor.FamilyName = vendor.FamilyName;
             }
             if (vendor.DisplayName != null && vendor.DisplayName != "")
             {
                 qboVendor.DisplayName = vendor.DisplayName;
             }
             if (vendor.CompanyName != null && vendor.CompanyName != "")
             {
                 qboVendor.CompanyName = vendor.CompanyName;
             }
             if (vendor.PrimaryPhone != null && vendor.PrimaryPhone != "")
             {
                 qboVendor.PrimaryPhone = new Intuit.Ipp.Data.TelephoneNumber {
                     FreeFormNumber = vendor.PrimaryPhone.ToString()
                 }
             }
             ;
             if (vendor.Mobile != null && vendor.Mobile != "")
             {
                 qboVendor.Mobile = new Intuit.Ipp.Data.TelephoneNumber {
                     FreeFormNumber = vendor.Mobile.ToString()
                 }
             }
             ;
             if (vendor.PrimaryEmailAddr != null && vendor.PrimaryEmailAddr != "")
             {
                 qboVendor.PrimaryEmailAddr = new Intuit.Ipp.Data.EmailAddress {
                     Address = vendor.PrimaryEmailAddr.ToString()
                 }
             }
             ;
             qboVendor.BillAddr = new Intuit.Ipp.Data.PhysicalAddress();
             if (vendor.BillAddrId != 0)
             {
                 qboVendor.BillAddr.Id = Convert.ToString(vendor.BillAddrId);
             }
             if (vendor.BillAddrLine1 != null && vendor.BillAddrLine1 != "")
             {
                 qboVendor.BillAddr.Line1 = vendor.BillAddrLine1;
             }
             if (vendor.BillAddrLine2 != null && vendor.BillAddrLine2 != "")
             {
                 qboVendor.BillAddr.Line2 = vendor.BillAddrLine2;
             }
             if (vendor.BillAddrCity != null && vendor.BillAddrCity != "")
             {
                 qboVendor.BillAddr.City = vendor.BillAddrCity;
             }
             if (vendor.BillAddrCountry != null && vendor.BillAddrCountry != "")
             {
                 qboVendor.BillAddr.Country = vendor.BillAddrCountry;
             }
             if (vendor.BillAddrCountrySubDivisionCode != null && vendor.BillAddrCountrySubDivisionCode != "")
             {
                 qboVendor.BillAddr.CountrySubDivisionCode = vendor.BillAddrCountrySubDivisionCode;
             }
             if (vendor.BillAddrPostalCode != null && vendor.BillAddrPostalCode != "")
             {
                 qboVendor.BillAddr.PostalCode = vendor.BillAddrPostalCode;
             }
             if (vendor.BillAddrLine1 != null && vendor.BillAddrLine1 != "")
             {
                 qboVendor.BillAddr.Line1 = vendor.BillAddrLine1;
             }
             vendorList.Add(qboVendor);
         }
         QBAuthorizationdto oAuthDetails = new QBOAuthService(new QBAuthorizationdto()).GetAccessToken(this);
         syncService            = new QBSyncService(oAuthDetails);
         syncObjects            = new QBSyncdto();
         syncObjects.OauthToken = oAuthDetails;
         syncObjects.CompanyId  = oAuthDetails.Realmid;
         syncObjects.VendorList = vendorList;
         if (syncObjects.VendorList.Count > 0)
         {
             syncObjects = syncService.SyncVendor(this, syncObjects);
         }
     }
     return("");
 }