コード例 #1
0
        public string ProcessTaxRates(NopCommerceDataReader dataReader, NopImportContext nopImportContext)
        {
            HashSet <TaxData> taxDatas = dataReader.GetTaxData();
            var site = _session.Get <Site>(_site.Id);

            _session.Transact(session =>
            {
                foreach (TaxData taxData in taxDatas)
                {
                    var taxRate = new TaxRate
                    {
                        Name       = taxData.Name,
                        Percentage = taxData.Rate,
                    };
                    taxRate.AssignBaseProperties(site);
                    session.Insert(taxRate);
                    nopImportContext.AddEntry(taxData.Id, taxRate);
                }
            });

            return(string.Format("{0} tax rates processed", taxDatas.Count));
        }