Example #1
0
        public Guid CreateCustomerAddressByCustomerDescription(string customerDescription, string type,
                                                               string firstName, string lastName,
                                                               string addressLine, string district, string city,
                                                               string zipCode, string countryCode,
                                                               string taxNumber, string taxOffice)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(customerDescription))
                {
                    throw new Exception("Customer description (B2C Id) must be provided");
                }

                NebimV3.CurrentAccounts.RetailCustomer customer = new NebimV3.CurrentAccounts.RetailCustomer();
                string customerCode = null;


                customerCode = FindCustomerCodeByDescription(customerDescription);
                customer.RetailCustomerCode = customerCode;
                if (!customer.ExistsInDB())
                {
                    throw new Exception("Customer does not exists. CustomerCode:" + customerCode);
                }
                return(CreateCustomerAddressByCustomerCode(customerCode, type, firstName, lastName, addressLine, district, city, zipCode, countryCode, taxNumber, taxOffice));
            }
            catch (Exception ex)
            {
                NebimV3.Library.V3Exception v3Ex = ex as NebimV3.Library.V3Exception;
                if (v3Ex != null)
                {
                    throw new Exception(NebimV3.ApplicationCommon.ExceptionHandlerBase.Default.GetExceptionMessage(v3Ex), ex);
                }
                throw;
            }
        }
Example #2
0
        public Guid CreateCustomerAddressByCustomerCode(string customerCode, string type,
                                                        string firstName, string lastName,
                                                        string addressLine, string district, string city,
                                                        string zipCode, string countryCode,
                                                        string taxNumber, string taxOffice)
        {
            try
            {
                // DB'de kayıtlı bir müşterinin Müşteri Kodu vasıtasıyla yüklenmesi
                NebimV3.CurrentAccounts.RetailCustomer customer = new NebimV3.CurrentAccounts.RetailCustomer();
                if (!string.IsNullOrWhiteSpace(customerCode))
                {
                    customer.RetailCustomerCode = customerCode;
                    if (!customer.ExistsInDB())
                    {
                        throw new Exception("Customer does not exists. customer code:" + customerCode);
                    }
                    customer.Load();
                }

                NebimV3.CurrentAccounts.CurrAccPostalAddress address = new NebimV3.CurrentAccounts.CurrAccPostalAddress(customer);
                //TODO: il, ilçeyi ayır
                addressLine             = string.Format(_nebimIntegrationSettings.AddressFormat, firstName, lastName, addressLine, district);
                address.AddressTypeCode = type; // 1:Ev adresi , 2: İş adresi
                address.Address         = addressLine.Substring(0, Math.Min(200, addressLine.Length));
                address.ZipCode         = zipCode == null ? null : zipCode.Substring(0, Math.Min(20, zipCode.Length));
                address.CountryCode     = countryCode;
                //address.StateCode = "TR.00"; // Marmara
                address.CityCode = city; // TR.34 İstanbul

                address.TaxNumber = taxNumber == null ? null : taxNumber.Substring(0, Math.Min(10, taxNumber.Length));
                if (!string.IsNullOrWhiteSpace(taxOffice))
                {
                    address.SetTaxOfficedescription(taxOffice.Substring(0, Math.Min(100, taxOffice.Length)));
                }
                address.SetCitydescription(city);
                if (!string.IsNullOrWhiteSpace(district))
                {
                    address.SetDistrictdescription(district.Substring(0, Math.Min(100, district.Length)));
                }
                address.SaveOrUpdate();
                customer.PostalAddresses.Add(address);
                return(address.PostalAddressID);
            }
            catch (Exception ex)
            {
                NebimV3.Library.V3Exception v3Ex = ex as NebimV3.Library.V3Exception;
                if (v3Ex != null)
                {
                    throw new Exception(NebimV3.ApplicationCommon.ExceptionHandlerBase.Default.GetExceptionMessage(v3Ex), ex);
                }
                throw;
            }
        }
Example #3
0
        public string CreateUpdateCustomer(string description, string languageCode, string firstName, string lastName,
                                           List <string> emails, List <string> phones, string identityNum, byte genderCode = 3, string customerSegment = null, DateTime?registerDate = null)
        {
            try
            {
                NebimV3.CurrentAccounts.RetailCustomer customer = new NebimV3.CurrentAccounts.RetailCustomer();

                //check if customer exists by B2C id in description filed.
                string customerCode = null;
                if (_nebimIntegrationSettings.API_CustomerCodePrefix == null)
                {
                    customerCode = this.FindCustomerCodeByDescription(description);
                }
                else
                {
                    customerCode = GetCustomerCodeFromB2CId(description);
                }
                customer.RetailCustomerCode = customerCode;
                if (customer.ExistsInDB())
                {
                    customer.Load();
                }


                //lets keep "B2C customer id" in description
                customer.RetailCustomerDescription = description;
                customer.DataLanguageCode          = languageCode;//TR,EN
                customer.FirstName = firstName;
                customer.LastName  = lastName;
                if (registerDate.HasValue)
                {
                    customer.AccountOpeningDate = registerDate.Value;
                }

                customer.IdentityNum             = identityNum;
                customer.PersonalInfo.GenderCode = genderCode;//1:erkek,2:kadın,3:bilimiyor
                //if (customerCode != null)
                //{
                customer.SaveOrUpdate();
                //}
                //else
                //{
                //    customer.Save();

                //    customerCode = customer.RetailCustomerCode;
                //}
                #region müşteri idsi özellik olarak ekleniyor

                //B2C customer id,
                //SetAttribute(1, description, customer);
                //müşteri seviyesi, müşteri seviyeleri açılmış olması gerekiyor. (müşteri özelliği 2 noyu kullnacağız)
                if (!string.IsNullOrWhiteSpace(customerSegment))
                {
                    //SetExistingAttribute(2, customerSegment, customer);
                    SetAttribute(2, customerSegment, customer);
                }

                #endregion müşteri idsi özellik olarak ekleniyor

                NebimV3.CurrentAccounts.CurrAccCommunication comm = null;
                customer.Communications.Load();
                #region CommunicationTypeCode
                //1	EN	Telephone
                //2	EN	Fax
                //3	EN	E-Mail
                //4	EN	Home Phone
                //5	EN	Office Phone
                //6	EN	Business Mobile
                //7	EN	Personal Mobile
                //1	TR	Telefon
                //2	TR	Fax
                //3	TR	E-Posta
                //4	TR	Ev Telefonu
                //5	TR	İş Telefonu
                //6	TR	İş Cep Telefonu
                //7	TR	Özel Cep Telefonu
                #endregion CommunicationTypeCode

                foreach (var email in emails)
                {
                    if (CommunicationExists(customer.Communications, email))
                    {
                        continue;
                    }
                    comm = new NebimV3.CurrentAccounts.CurrAccCommunication(customer);
                    comm.CommunicationTypeCode = _nebimIntegrationSettings.API_CommunicationTypeEmail;
                    comm.CommAddress           = email;
                    comm.Save();
                    customer.Communications.Add(comm);
                }
                foreach (var phone in phones)
                {
                    if (CommunicationExists(customer.Communications, phone))
                    {
                        continue;
                    }
                    comm = new NebimV3.CurrentAccounts.CurrAccCommunication(customer);
                    comm.CommunicationTypeCode = _nebimIntegrationSettings.API_CommunicationTypePhone;
                    comm.CommAddress           = phone;
                    comm.Save();
                    customer.Communications.Add(comm);
                }
                return(customerCode); // Kaydederken otomatik olarak bir numara verilir. Bu numarayı kullanacağız.
            }
            catch (Exception ex)
            {
                NebimV3.Library.V3Exception v3Ex = ex as NebimV3.Library.V3Exception;
                if (v3Ex != null)
                {
                    throw new Exception(NebimV3.ApplicationCommon.ExceptionHandlerBase.Default.GetExceptionMessage(v3Ex), ex);
                }
                throw;
            }
        }