public OrderService(bool useDataFiller) { if (useDataFiller) { DataContext dataContext = new DataContext(); IDataFiller dataFiller = new DataFactory(); dataFiller.Fill(dataContext); IdGenerator.ClientNum = dataContext.Customers.Count + 1; IdGenerator.OrderNum = dataContext.Orders.Count + 1; CustomerRepository customerRepository = new CustomerRepository(dataContext); MerchandiseRepository merchandiseRepository = new MerchandiseRepository(dataContext); OrderRepository orderRepository = new OrderRepository(dataContext); ICustomerService customerService = new CustomerService(customerRepository); IMerchandiseService merchandiseService = new MerchandiseService(merchandiseRepository); _orderRepository = orderRepository; _customerService = customerService; _merchandiseService = merchandiseService; _provider = new DiscountCreator(_merchandiseService); } else { _customerService = new CustomerService(); _merchandiseService = new MerchandiseService(); _orderRepository = new OrderRepository(); } _cyclicDiscountService = new CyclicDiscountService(0.3, TimeSpan.FromSeconds(20), _provider); _cyclicDiscountService.Start(); }
public OrderService() { _customerService = new CustomerService(); _merchandiseService = new MerchandiseService(); _orderRepository = new OrderRepository(); _provider = new DiscountCreator(_merchandiseService); _cyclicDiscountService = new CyclicDiscountService(0.3, TimeSpan.FromSeconds(20), _provider); _cyclicDiscountService.Start(); }
public OrderService(IRepository <Order> orderRepository, ICustomerService customerService, IMerchandiseService merchandiseService, CyclicDiscountService cyclicDiscountService) { _orderRepository = orderRepository; _customerService = customerService; _merchandiseService = merchandiseService; _provider = new DiscountCreator(_merchandiseService); _cyclicDiscountService = cyclicDiscountService; _provider = _cyclicDiscountService.Provider; _cyclicDiscountService.Start(); }