aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Controllers')
-rw-r--r--Controllers/CheckOrdersController.cs17
-rw-r--r--Controllers/Controller.cs10
-rw-r--r--Controllers/MainController.cs28
-rw-r--r--Controllers/OrderPizzaController.cs105
4 files changed, 160 insertions, 0 deletions
diff --git a/Controllers/CheckOrdersController.cs b/Controllers/CheckOrdersController.cs
new file mode 100644
index 0000000..861fb2e
--- /dev/null
+++ b/Controllers/CheckOrdersController.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using KukaPizza.Models;
+using KukaPizza.Views;
+
+namespace KukaPizza.Controllers
+{
+ public class CheckOrdersController : Controller
+ {
+ private static Database db = Database.Instance;
+
+ public List<PizzaOrder> Orders { get { return db.Orders; } }
+ public CheckOrdersController()
+ {
+ new CheckOrdersView(this);
+ }
+ }
+} \ No newline at end of file
diff --git a/Controllers/Controller.cs b/Controllers/Controller.cs
new file mode 100644
index 0000000..afa7295
--- /dev/null
+++ b/Controllers/Controller.cs
@@ -0,0 +1,10 @@
+using System;
+using KukaPizza.Views;
+
+namespace KukaPizza.Controllers
+{
+ public abstract class Controller
+ {
+
+ }
+} \ No newline at end of file
diff --git a/Controllers/MainController.cs b/Controllers/MainController.cs
new file mode 100644
index 0000000..b7167e5
--- /dev/null
+++ b/Controllers/MainController.cs
@@ -0,0 +1,28 @@
+using System;
+using KukaPizza.Views;
+
+namespace KukaPizza.Controllers
+{
+ public class MainController : Controller
+ {
+ public MainController()
+ {
+ new MainView(this);
+ }
+
+ public void OpenOrderPizza()
+ {
+ new OrderPizzaController();
+ }
+
+ public void OpenCheckOrders()
+ {
+ new CheckOrdersController();
+ }
+
+ public void Close()
+ {
+ System.Environment.Exit(0);
+ }
+ }
+} \ No newline at end of file
diff --git a/Controllers/OrderPizzaController.cs b/Controllers/OrderPizzaController.cs
new file mode 100644
index 0000000..acee28a
--- /dev/null
+++ b/Controllers/OrderPizzaController.cs
@@ -0,0 +1,105 @@
+using System.Collections.Generic;
+using KukaPizza.Adapters;
+using KukaPizza.Builders;
+using KukaPizza.Models;
+using KukaPizza.Views;
+
+namespace KukaPizza.Controllers
+{
+ public class OrderPizzaController : Controller
+ {
+ private static Database db = Database.Instance;
+
+ public Pizza[] Pizzas { get { return db.Pizzas; } }
+
+ public Topping[] Toppings { get { return db.Toppings; } }
+ private static List<int> _selectedToppings = new List<int>();
+ public List<int> SelectedToppings { get { return _selectedToppings; } }
+
+ private PizzaOrder _order;
+ public PizzaOrder Order { get { return _order; } }
+
+ private PizzaBuilder pb = new PizzaBuilder();
+
+ public OrderPizzaController()
+ {
+ new OrderPizzaStep1View(this);
+ }
+
+ public void ChooseBasePizza(int number)
+ {
+ try
+ {
+ pb.ChooseBase(db.Pizzas[number]);
+ }
+ catch { }
+ }
+
+ public void SelectTopping(int number)
+ {
+ _selectedToppings.Add(number);
+ }
+
+ public void AddExtraToppings()
+ {
+ List<Topping> extraToppings = new List<Topping>();
+ foreach (var s in _selectedToppings)
+ {
+ extraToppings.Add(db.Toppings[s]);
+ }
+
+ pb.AddExtraToppings(extraToppings);
+ }
+
+ public void ChooseSize(int number)
+ {
+ PizzaSize size;
+
+ switch (number)
+ {
+ case 1:
+ size = PizzaSize.Small;
+ break;
+ case 2:
+ size = PizzaSize.Medium;
+ break;
+ case 3:
+ size = PizzaSize.Large;
+ break;
+ default:
+ size = PizzaSize.Medium;
+ break;
+ }
+ pb.ChooseSize(size);
+
+ _order = pb.GetResult();
+ }
+
+ public void MakePaymentWithVisa()
+ {
+ IPayment payment = new VisaPayment();
+ payment.Pay(Order.GetPrice());
+ }
+
+ public void MakePaymentWithMastercard()
+ {
+ IPayment payment = new MasterCardPaymentAdapter();
+ payment.Pay(Order.GetPrice());
+ }
+
+ public void ConfirmOrder()
+ {
+ _selectedToppings = new List<int>();
+ db.Orders.Add(_order);
+ }
+
+ public void CancelOrder()
+ {
+ }
+
+ public void GoBackToMainView()
+ {
+ new MainController();
+ }
+ }
+} \ No newline at end of file