-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOrderInfoCollection.cs
276 lines (234 loc) · 8.52 KB
/
OrderInfoCollection.cs
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
using System;
using System.Collections.Generic;
namespace GettingStarted
{
public class OrderInfoCollection : IDisposable
{
public OrderInfoCollection()
{
OrdersListDetails = new OrderInfoRepository().GetListOrdersDetails(2000);
}
private List<OrderInfo> _ordersListDetails;
/// <summary>
/// Gets or sets the orders details.
/// </summary>
/// <value>The orders details.</value>
public List<OrderInfo> OrdersListDetails
{
get { return _ordersListDetails; }
set { _ordersListDetails = value; }
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool isdisposable)
{
if (this.OrdersListDetails != null)
{
this.OrdersListDetails.Clear();
}
}
}
public class OrderInfoRepository
{
int customerIdCount = 0;
/// <summary>
/// Initializes a new instance of the <see cref="OrderInfoRepository"/> class.
/// </summary>
public OrderInfoRepository()
{
}
/// <summary>
/// Gets the orders details.
/// </summary>
/// <param name="count">The count.</param>
/// <returns></returns>
public List<OrderInfo> GetListOrdersDetails(int count)
{
List<OrderInfo> ordersDetails = new List<OrderInfo>();
if (ShipCity.Count == 0)
SetShipCity();
for (int i = 10000; i < count + 10000; i++)
{
ordersDetails.Add(GetOrder(i));
}
return ordersDetails;
}
Random r = new Random(1);
/// <summary>
/// Gets the order.
/// </summary>
/// <param name="i">The i.</param>
/// <returns></returns>
private OrderInfo GetOrder(int i)
{
var shipcountry = ShipCountry[r.Next(5)];
var shipcitycoll = ShipCity[shipcountry];
var order = new OrderInfo();
order.OrderID = i;
order.OrderDate = new DateTime(r.Next(2011, 2013), r.Next(1, 12), r.Next(1, 28));
order.ProductName = productName[r.Next(5)];
order.CustomerID = GetCustomerID(i);
order.UnitPrice = unitPrice[r.Next(35)];
order.Quantity = r.Next(20, 60);
order.ShipCountry = shipcountry;
order.ContactNumber = 999111235 + i;
return order;
}
string GetCustomerID(int i)
{
if (i % 4 != 0 || i == 0)
{
return CustomerID[customerIdCount];
}
else
{
if (i % 4 == 0)
customerIdCount++;
if (customerIdCount > 9)
customerIdCount = 0;
return CustomerID[customerIdCount];
}
}
double[] unitPrice = new double[] { 28.5, 336.2, 88.3, 86, 512, 41, 253.3, 33, 87, 45.1, 78.3, 19, 56.7, 23.3, 59, 91, 32.8, 264.5, 63.7, 434.2, 15.9, 21.9, 45, 70.3, 42.5, 67.2, 34.9, 379.9, 0, 59.2, 412.6, 19.8, 42.7, 78, 26.8 };
string[] ShipCountry = new string[]
{
"Argentina",
"Austria",
"Belgium",
"Brazil",
"Canada",
"Denmark",
"Finland",
"France",
"Germany",
"Ireland",
"Italy",
"Mexico",
"Norway",
"Poland",
"Portugal",
"Spain",
"Sweden",
"Switzerland",
"UK",
"USA",
"Venezuela"
};
/// <summary>
/// Collection of ProductNames
/// </summary>
string[] productName = new string[]
{
"Alice Mutton",
"NuNuCa Nuß-Nougat-Creme",
"Boston Crab Meat",
"Raclette Courdavault",
"Wimmers gute",
"Gorgonzola Telino",
"Chartreuse verte",
"Fløtemysost",
"Carnarvon Tigers",
"Thüringer",
"Vegie-spread",
"Tarte au sucre",
"Konbu",
"Valkoinen suklaa",
"Queso Manchego",
"Perth Pasties",
"Vegie-spread",
"Tofu",
"Sir Rodney's",
"Manjimup Dried Apples"
};
Dictionary<string, string[]> ShipCity = new Dictionary<string, string[]>();
/// <summary>
/// Sets the ship city.
/// </summary>
private void SetShipCity()
{
string[] argentina = new string[] { "Buenos Aires" };
string[] austria = new string[] { "Graz", "Salzburg" };
string[] belgium = new string[] { "Bruxelles", "Charleroi" };
string[] brazil = new string[] { "Campinas", "Resende", "Rio de Janeiro", "São Paulo" };
string[] canada = new string[] { "Montréal", "Tsawassen", "Vancouver" };
string[] denmark = new string[] { "Århus", "København" };
string[] finland = new string[] { "Helsinki", "Oulu" };
string[] france = new string[] { "Lille", "Lyon", "Marseille", "Nantes", "Paris", "Reims", "Strasbourg", "Toulouse", "Versailles" };
string[] germany = new string[] { "Aachen", "Berlin", "Brandenburg", "Cunewalde", "Frankfurt a.M.", "Köln", "Leipzig", "Mannheim", "München", "Münster", "Stuttgart" };
string[] ireland = new string[] { "Cork" };
string[] italy = new string[] { "Bergamo", "Reggio Emilia", "Torino" };
string[] mexico = new string[] { "México D.F." };
string[] norway = new string[] { "Stavern" };
string[] poland = new string[] { "Warszawa" };
string[] portugal = new string[] { "Lisboa" };
string[] spain = new string[] { "Barcelona", "Madrid", "Sevilla" };
string[] sweden = new string[] { "Bräcke", "Luleå" };
string[] switzerland = new string[] { "Bern", "Genève" };
string[] uk = new string[] { "Colchester", "Hedge End", "London" };
string[] usa = new string[] { "Albuquerque", "Anchorage", "Boise", "Butte", "Elgin", "Eugene", "Kirkland", "Lander", "Portland", "San Francisco", "Seattle", "Walla Walla" };
string[] venezuela = new string[] { "Barquisimeto", "Caracas", "I. de Margarita", "San Cristóbal" };
ShipCity.Add("Argentina", argentina);
ShipCity.Add("Austria", austria);
ShipCity.Add("Belgium", belgium);
ShipCity.Add("Brazil", brazil);
ShipCity.Add("Canada", canada);
ShipCity.Add("Denmark", denmark);
ShipCity.Add("Finland", finland);
ShipCity.Add("France", france);
ShipCity.Add("Germany", germany);
ShipCity.Add("Ireland", ireland);
ShipCity.Add("Italy", italy);
ShipCity.Add("Mexico", mexico);
ShipCity.Add("Norway", norway);
ShipCity.Add("Poland", poland);
ShipCity.Add("Portugal", portugal);
ShipCity.Add("Spain", spain);
ShipCity.Add("Sweden", sweden);
ShipCity.Add("Switzerland", switzerland);
ShipCity.Add("UK", uk);
ShipCity.Add("USA", usa);
ShipCity.Add("Venezuela", venezuela);
}
string[] CustomerID = new string[]
{
"ALFKI",
"FRANS",
"MEREP",
"FOLKO",
"SIMOB",
"WARTH",
"VAFFE",
"FURIB",
"SEVES",
"LINOD",
"RISCU",
"PICCO",
"BLONP",
"WELLI",
"FOLIG",
"SHIWL",
"ASDFI",
"YIWOL",
"SIEPZ",
"UIKOC",
"BNUTQ",
"FDKIO",
"UJIKW",
"QOLPX",
"WJXKO",
"SXEWD",
"ZXSOL",
"KKMJU",
"QMICP",
"SJWII",
"WDOPO",
"SAIOP",
"SSOLE",
"CUEMC",
"HWIMQ"
};
}
}