/// <summary> /// Removes a Product from SalesOrder by added a OrderLine that has a negative quantity. /// </summary> /// <param name="product">The Product to be removed from the SalesOrder.</param> /// <param name="quantity">The quantity of the Product.</param> /// <param name="discount">A discount on the product. Can be null.</param> public void RemoveProductFromOrder(Product product, int quantity, Discount discount) { _orderController.AddProduct(product, -quantity, discount); }
/// <summary> /// Adds products to the current SalesOrder. /// </summary> /// <param name="product">The Product to be added to the SalesOrder.</param> /// <param name="quantity">The quantity of the Product. Can be negative.</param> /// <param name="discount">A discount on the product. Can be null.</param> public void AddProductToOrder(Product product, int quantity, Discount discount) { _orderController.AddProduct(product, quantity, discount); _logger.Debug("Product Added"); }
public void SetUp() { _raisedEvent = 0; _discount = new Discount(); _product = new Product("Test", 100, true); _printer = Substitute.For<IPrinter>(); _cashDrawer = Substitute.For<ICashDrawer>(); _dalFacade = Substitute.For<IDalFacade>(); _productDao = new ProductDao(_dalFacade); _paymentDao = new PaymentDao(_dalFacade); _orderDao = new OrderDao(_dalFacade); _receiptController = new ReceiptController(_printer); _productController = new ProductController(_productDao); var paymentProviders = new List<IPaymentProvider> { new CashPayment() }; _paymentController = new PaymentController(paymentProviders, _receiptController, _paymentDao, _cashDrawer); _orderController = new OrderController(_orderDao); _salesController = new SalesController(_orderController, _receiptController, _productController, _paymentController); }
private static void Main(string[] args) { _logger = LogFactory.GetLogger(typeof (Program)); IDatabaseInitializer<CashRegisterContext> seed; // Empty // seed = new EmptyInitializer(); // Kalle Seed //seed = new CashProductInitializer(); // Lærke Seed seed = new FullProductInitializer(); using (var contex = new CashRegisterContext(seed)) { Console.WriteLine("FLAF"); contex.Database.Initialize(true); contex.SaveChanges(); } IDalFacade dalFacade = new DalFacade(); IProductDao pd = new ProductDao(dalFacade); IProductController pc = new ProductController(pd); SalesOrder o; using (var uow = dalFacade.UnitOfWork) { var d = new Discount { Description = "Discount", Percent = 0, }; uow.DiscountRepository.Insert(d); uow.Save(); o = new SalesOrder { Date = DateTime.Now, Status = OrderStatus.Created, }; uow.SalesOrderRepository.Insert(o); } using (var uow = dalFacade.UnitOfWork) { var t = new Transaction { Date = DateTime.Now, Description = "Flaf", PaymentType = PaymentType.Cash, Price = 20, SalesOrder = o, Status = TransactionStatus.Created }; uow.TransactionRepository.Insert(t); uow.Save(); } Console.WriteLine("ProductTabs"); foreach (var productTab in pc.ProductTabs) { Console.WriteLine(productTab.Priority + ": " + productTab.Name); foreach (var productType in productTab.ProductTypes) { Console.WriteLine("\t" + productType.Name); foreach (var productGroup in productType.ProductGroups) { Console.WriteLine("\t\t" + productGroup.Name); foreach (var product in productGroup.Products) { Console.WriteLine("\t\t\t" + product.Name); } } } } _logger.Fatal("Fatal"); _logger.Err("Error"); _logger.Warn("Warn"); _logger.Info("Info"); _logger.Debug("Debug"); }
/// <summary> /// Adds an amount of products to the current order. /// </summary> /// <param name="product">Product to be added to the SalesOrder.</param> /// <param name="quantity">The quantity of the product. Can be negative.</param> /// <param name="discount">The discount on the product. Can be null.</param> public void AddProduct(Product product, int quantity, Discount discount) { var orderLine = new OrderLine { SalesOrder = CurrentOrder, Product = product, Quantity = quantity, Discount = discount, UnitPrice = product.Price, DiscountValue = (discount == null ? 0 : discount.Percent / 100 * product.Price) }; OrderDao.AddOrderLine(orderLine); OnPropertyChanged(nameof(CurrentOrder)); }