forked from devxzero/blogpost_files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Service.cs
48 lines (35 loc) · 1.14 KB
/
Service.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
namespace mvcapp.Models
{
using System.Collections.Generic;
public class Service
{
#region Constants and Fields
private static readonly List<Category> categories = new List<Category>();
private static readonly List<Product> products = new List<Product>();
#endregion
#region Constructors and Destructors
static Service()
{
for (var i = 0; i < 5; i++)
{
string name = (1000 + i).ToString();
categories.Add(new Category(name));
}
for (var i = 0; i < 20000; i++)
{
string name = i.ToString();
string description = (i * i).ToString();
var product = new Product(name, i, description);
product.Categories.AddRange(categories);
products.Add(product);
}
}
#endregion
#region Public Methods
public static List<Product> GetProducts(int max)
{
return products.GetRange(0, max);
}
#endregion
}
}