blob: acee28aafc2e0f0ccab69eb951e689e9e641dd5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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();
}
}
}
|