public void create_one_complete_order() { IManager manager = new Manager(); ICustomer customer = FactoryCustomer.CreateNew(); manager.AddCustomer(customer); // create Vat Vat vat = new Vat(20); manager.AddVat(vat); var random = new Random(); ICompany store = new Company(); manager.AddCompany(store); // create products List <IProduct> products = FactoryProduct.CreateMultipleProducts(random.Next(5, 15), random.Next(50, 150), vat, manager, store); foreach (Product _product in products) { manager.AddProduct(_product); Console.WriteLine($"Product #{_product.Id}: {_product.Name}, vat : {_product.Vat.percent}%, price without vat : {_product.Price} €, price with vat : {_product.GetPriceWithVAT()} €"); } // create an order Order order = new Order(customer, products); Console.WriteLine($"Order #{order.Id}: {order.Products.Count} products, price : {order.GetTotalPrice()} €, price with vat : {order.GetTotalPriceWithVAT()} €, vat margin : {order.GetVatMargin()} € "); Assert.Greater(products.Count, 1); //Assert.IsTrue(order.Products.Count > 1); }
public void assign_a_customer_to_order() { IOrder order = new Order(); ICustomer customer = FactoryCustomer.CreateNew(); order.Customer = customer; Assert.NotNull(order.Customer); }
private List <CustomerBase> LoadGrid() { IRepository <CustomerBase> dal = null; dal = FactoryCustomer.CreateDAL("CustomerDAL"); IUow unitOfWork = (IUow)FactoryCustomer.CreateUOW(); dal.SetUnitOfWork(unitOfWork); return(dal.GetAll()); }
public void add_a_customer_to_manager() { var manager = new Manager(); ICustomer customer = FactoryCustomer.CreateNew(); manager.AddCustomer(customer); int productsCount = manager.GetCustomers().Count; Console.WriteLine($"Manager : customers count : {productsCount}"); Assert.AreEqual(productsCount, 1); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text == "Customer") { customer = null; customer = (ICustomer)FactoryCustomer.Create("Customer"); } if (comboBox1.Text == "Lead") { customer = null; customer = (ICustomer)FactoryCustomer.Create("Lead"); } //initial values customer.CustomerName = textBox_CustomerName.Text; customer.PhoneNumber = textBox1_PhoneNumber.Text; }
public void create_ten_customers_on_the_fly() { int count = 0; while (count < 10) { count++; var customer = FactoryCustomer.CreateNew(); var sex = ""; if (customer.Sex == 1) { sex = "Male"; } else { sex = "Female"; } Console.WriteLine($"Customer #{count}: {customer.Name}, Sex : {sex}"); Assert.IsNotNull(customer.Name); } }
private void button2_Click(object sender, EventArgs e) { //validate first customer.Validate(); IRepository <CustomerBase> dal = null; dal = FactoryCustomer.CreateDAL("CustomerDAL"); //get customer base instance using factory CustomerBase customerBase = new CustomerBase(); //get customer base instance using factory IUow unitOfWork = (IUow)FactoryCustomer.CreateUOW(); //Map customerBase.Address = customer.Address; customerBase.BillAmount = customer.BillAmount; customerBase.BillDate = customer.BillDate; customerBase.Address = customer.Address; customerBase.PhoneNumber = customer.PhoneNumber; customerBase.CustomerName = customer.CustomerName; try { dal.SetUnitOfWork(unitOfWork); dal.Add(customerBase); //dal.Save(customerBase); unitOfWork.Committ(); //use unit-of-work design pattern dataGridView1.DataSource = LoadGrid(); } catch { unitOfWork.Rollback(); } }