コード例 #1
0
 public static void ImportTax(string path)
 {
     using (var uw = new UnitOfWork())
     {
         var municipalities = uw.MunicipalityRepository.Get(tax => true);
         var result         = new ImportTax(path).Read(municipalities);
         {
             foreach (var tax in result)
             {
                 if (tax.Id == 0)
                 {
                     uw.TaxRepository.Add(tax);
                 }
                 else
                 {
                     var existingTax = uw.TaxRepository.GetById(tax.Id);
                     if (existingTax == null)
                     {
                         uw.TaxRepository.Add(tax);
                     }
                     else
                     {
                         UpdateTax(tax.Id, tax);
                     }
                 }
             }
             uw.SaveChanges();
         }
     }
 }
コード例 #2
0
ファイル: TaxTests.cs プロジェクト: oanadonose/TaxApp
        public void ImportTaxCalculation(string name, Double p, Double e)
        {
            Decimal   price  = Convert.ToDecimal(p);
            Decimal   expTax = Convert.ToDecimal(e);
            ImportTax bst    = new ImportTax();

            Decimal tax = bst.Calculate(name, price);

            Assert.AreEqual(expTax, tax);
        }
コード例 #3
0
        private double CalculateTax(Product product)
        {
            double  taxToApply        = 0;
            BaseTax baseTax           = new BaseTax(product);
            double  calculatedBaseTax = baseTax.Calculate();

            taxToApply += calculatedBaseTax;

            if (product.Category == ProductCategory.Other)
            {
                RegularTax regularTax           = new RegularTax(product);
                double     calculatedRegularTax = regularTax.Calculate();
                taxToApply += calculatedRegularTax;
            }

            if (product.IsImported)
            {
                ImportTax importTax           = new ImportTax(product);
                double    calculatedImportTax = importTax.Calculate();
                taxToApply += calculatedImportTax;
            }

            return(taxToApply);
        }