Пример #1
0
        public string ProcessAddresses(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            var addressData = dataReader.GetAddressData();
            _session.Transact(session =>
            {
                foreach (var data in addressData)
                {
                    var country = nopImportContext.FindNew<Country>(data.Country.GetValueOrDefault());
                    var address = new Address
                    {
                        Address1 = data.Address1,
                        Address2 = data.Address2,
                        City = data.City,
                        Company = data.Company,
                        CountryCode = country == null ? string.Empty : country.ISOTwoLetterCode,
                        FirstName = data.FirstName,
                        LastName = data.LastName,
                        PhoneNumber = data.PhoneNumber,
                        PostalCode = data.PostalCode,
                        StateProvince = data.StateProvince,
                    };

                    session.Save(address);
                    nopImportContext.AddEntry(data.Id, address);
                }
            });
            return string.Format("{0} addresses added", addressData.Count);
        }
Пример #2
0
        public string ProcessAddresses(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            var addressData = dataReader.GetAddressData();

            _session.Transact(session =>
            {
                foreach (var data in addressData)
                {
                    var country = nopImportContext.FindNew <Country>(data.Country.GetValueOrDefault());
                    var address = new Address
                    {
                        Address1      = data.Address1,
                        Address2      = data.Address2,
                        City          = data.City,
                        Company       = data.Company,
                        CountryCode   = country == null ? string.Empty : country.ISOTwoLetterCode,
                        FirstName     = data.FirstName,
                        LastName      = data.LastName,
                        PhoneNumber   = data.PhoneNumber,
                        PostalCode    = data.PostalCode,
                        StateProvince = data.StateProvince,
                    };

                    session.Save(address);
                    nopImportContext.AddEntry(data.Id, address);
                }
            });
            return(string.Format("{0} addresses added", addressData.Count));
        }
Пример #3
0
        public string ProcessAddresses(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            var addressData = dataReader.GetAddressData();
            var site        = _session.Get <Site>(_site.Id);

            _session.Transact(session =>
            {
                foreach (var data in addressData)
                {
                    var address = new Address
                    {
                        Address1      = data.Address1,
                        Address2      = data.Address2,
                        City          = data.City,
                        Company       = data.Company,
                        CountryCode   = data.CountryCode,
                        FirstName     = data.FirstName,
                        LastName      = data.LastName,
                        PhoneNumber   = data.PhoneNumber,
                        PostalCode    = data.PostalCode,
                        StateProvince = data.StateProvince,
                    };
                    address.AssignBaseProperties(site);
                    session.Insert(address);
                    nopImportContext.AddEntry(data.Id, address);
                }
            });
            return(string.Format("{0} addresses added", addressData.Count));
        }