static void Main(string[] args) { double basicSalary; double currentSalary; Console.Write("Basic Salary: "); bool resultBasicSalary = Double.TryParse(Console.ReadLine(), out basicSalary); Console.Write("Current Salary: "); bool resultCurrentSalary = Double.TryParse(Console.ReadLine(), out currentSalary); Console.WriteLine("-------------------------------------------------"); if (resultBasicSalary && resultCurrentSalary) { ITaxFactory taxFactory = new TaxFactory(basicSalary >= 0 ? basicSalary : 0, currentSalary >= 0 ? currentSalary : 0); ITax tax = taxFactory.CreateTax(); Console.WriteLine(tax); } else { Console.WriteLine("Couldn't parse to Double"); } Console.ReadKey(); }
public void Setup() { mock = MockRepository.GenerateMock<IOrdersRepository>(); stub = MockRepository.GenerateStub<ITax>(); ordersRepositoryTestClass = new OrdersRepositoryTestClass(); listOrders = new List<Order>(); Order order = new Order(); order.AddItem(LineItemFactory.GetLineItem("book", 12.49M,1,ItemType.Exempt)); order.AddItem(LineItemFactory.GetLineItem("CD", 14.99M, 1,ItemType.Basic)); order.AddItem(LineItemFactory.GetLineItem("chocolate bar", 0.85M, 1, ItemType.Exempt)); listOrders.Add(order); order = new Order(); order.AddItem(LineItemFactory.GetLineItem("imported chocolates", 10.0M, 1, ItemType.Import)); order.AddItem(LineItemFactory.GetLineItem("imported perfume", 47.5M, 1, ItemType.Basic | ItemType.Import)); listOrders.Add(order); order = new Order(); order.AddItem(LineItemFactory.GetLineItem("imported perfume", 27.99M, 1, ItemType.Basic | ItemType.Import)); order.AddItem(LineItemFactory.GetLineItem("perfume", 18.99M, 1, ItemType.Basic)); order.AddItem(LineItemFactory.GetLineItem("pills", 19.75M, 1, ItemType.Exempt)); order.AddItem(LineItemFactory.GetLineItem("imported chocolates", 1.25M,1, ItemType.Import)); listOrders.Add(order); }
public ProductApp() { _context = new ApplicationContext(); _stockTrack = new StockTrackApp(); _tax = new TaxApp(); _discount = new AppDiscount(); _stock = new StockApp(); }
public Order(IFactory factory, IEnumerable<ShippingMethod> shippingMethods) { _shippingMethods = shippingMethods; _lines = new List<OrderLine>(); _discounts = new List<IDiscount>(); _factory = factory; _tax = _factory.CreateTax(); }
public static void AddTax(this IList<TaxAmount> amounts, ITax tax, decimal taxBase) { var taxAmount = amounts.Where(ta => ta.Tax.Name == tax.Name && ta.Tax.Rate == tax.Rate).FirstOrDefault(); if (taxAmount == null && taxBase != 0) { taxAmount = new TaxAmount(tax); amounts.Add(taxAmount); } taxAmount.TaxBase += taxBase; }
static void Main(string[] args) { ITax t = Factory.Create(1); t = Factory.Create(0); t.Calculate(); }
public static void AddTax(this IList <TaxAmount> amounts, ITax tax, decimal taxBase) { var taxAmount = amounts.Where(ta => ta.Tax.Name == tax.Name && ta.Tax.Rate == tax.Rate).FirstOrDefault(); if (taxAmount == null && taxBase != 0) { taxAmount = new TaxAmount(tax); amounts.Add(taxAmount); } taxAmount.TaxBase += taxBase; }
public EmployeeController(IEmployeeRepository employeeRepository, ITax taxEmployee) { repository = employeeRepository; this.taxEmployee = taxEmployee; pageInfo = new PageInfo { CountEmployees = repository.Employees.Count(), CountEmployeesPage = PageSize, CurrentPage = 1 }; PageSize = 3; }
static void Main(string[] args) { Console.WriteLine("Hello To Design Patterns!"); IExport export = new ExportToExcel(); export.Save(); export = new ExportToWord(); export.Save(); Console.WriteLine("Adapter : Before"); ThirdPartyLibraryExportPDF thirdPartyLibraryExportPDF = new ThirdPartyLibraryExportPDF(); thirdPartyLibraryExportPDF.Export(); Console.WriteLine("Adapter : After"); export = new PDFExportAdaptor(); export.Save(); Console.WriteLine("Factory : Before"); //ITax tax = new Tax1(); ITax tax = new NewTax();//No decoupling because each time there is a change //we need to change it here in the client side. Solution: centralise the New Keyword/Create tax.Calculate(); Console.WriteLine("Factory : After"); ITax tx = SimpleFactory.Create(1); tx.Calculate(); Console.WriteLine("Iterator : Before"); Report report = new Report(); report.GetCountries(); Console.WriteLine("Iterator : After"); IEnumerable <Country> coun = report.GetCountries(); Console.ReadLine(); }
public decimal CalculateTotal(Customer customer) { decimal total = 0.0m; foreach (var item in orderItems) { total += item.Cost * item.Quantity; } //var a = orderItems.Sum((item) => //{ // return item.Cost * item.Quantity; //}); ITax tax = _taxFactory.GetTax(); total += tax.CalculateTaxes(customer, total); return(total); }
public abstract void SetTax(ITax tax);
public SalesItemTaxDecorator(ISalesItem salesItem, ITax salesTax) { this._decoratedSalesItem = salesItem; this._salesTax = salesTax; }
public Report (IEnumerable<Employee> employees, ITax taxSalary) { Employees = employees; TaxSalary = taxSalary; }
public LineItemTaxDecorator(ILineItem lineItem, ITax lineTax) { this._decoratedLineItem = lineItem; this._lineTax = lineTax; }
/// <summary> /// for test /// </summary> public DeleteTaxBand(int taxBandID, ITax mockTaxDal) : this(taxBandID) { _TaxDal = mockTaxDal; }
public TaxAmount(ITax tax) { Tax = tax; }
public Report(IEnumerable <Employee> employees, ITax taxSalary) { Employees = employees; TaxSalary = taxSalary; }
//private readonly ICatalogSearchService _catalogSearchService; public CalculateCartTaxesObserver(ITax taxSettings) { _taxSettings = taxSettings; //_catalogSearchService = catalogService; }
public Product(IPriceCurve curve, ITax tax) { Curve = curve; Tax = tax; }
/// <summary> /// for test /// </summary> public CreateTaxBand(decimal bandMin, decimal taxRate, ITax mockTaxDal) : this(bandMin, taxRate) { _TaxDal = mockTaxDal; }
public MyBids(ITax used) { this.Tax = used; }
public void AddTax(ITax tax, decimal taxBase) { _taxes.AddTax(tax, taxBase); }
public GoldWallet(float ammount, ITax gst) { Balance = ammount; GSTonGold = gst; }
public TaxableProduct(ITax tax) { _tax = tax; }
/// <summary> /// for test /// </summary> public GetTax(ITax mockTaxDal) { _TaxDal = mockTaxDal; }
public Tax(ITax iTax) { Name = iTax.Name; Rate = iTax.Rate; }
public ListController() { this.ControllerName = "List"; this.taxBO = this.taxBO ?? new TaxBO(); this.unitBO = this.unitBO ?? new UnitBO(); }
public Product(IPriceCurve curve, ITax tax, IPriceDeduction deduction) { Curve = curve; Tax = tax; Deduction = deduction; }
public Milk(decimal taxableAmount, ITax tax) : base(tax) { Name = nameof(Milk); TaxableAmount = taxableAmount; }
public Calculator() { this._tax = tax; }
public CalculateOrderTaxesObserver(ITax taxSettings) { _taxSettings = taxSettings; }
//private readonly TaxSvc _taxService; public AvaTaxController(ITax taxSettings)//, TaxSvc taxService) { _taxSettings = taxSettings; //_taxService = taxService; }
public override void SetTax(ITax tax) { Tax = tax; }
public OrderCarlosVancouver() { Tax = new VancouverTax(); }
public void CalculatesTax(Budget budget, ITax tax) { Console.WriteLine(tax.Calculate(budget)); }
public void Process(Invoice invoice, ITax tax) { tax.Calculate(invoice); Console.WriteLine($"Invoice to '{invoice.Name}' generated with sucess, value with tax: {invoice.Value}"); }
/// <summary> /// for test /// </summary> public SaveTaxCutoffPoint(decimal taxCutoffPoint, decimal taxForeignCutoffPoint, ITax mockTaxDal) : this(taxCutoffPoint, taxForeignCutoffPoint) { _TaxDal = mockTaxDal; }
public OrderLine(IFactory factory) { _factory = factory; _tax = _factory.CreateTax(); _modifiers = new List<Modifier>(); }