-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSampleData.cs
112 lines (106 loc) · 4.81 KB
/
SampleData.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
using System.Data;
namespace BlazorAppWordProcessing
{
public class SampleData
{
public List<Recipient> RecipientList { get; }
public List<Sender> SenderList { get; }
DataTable dataTable;
public SampleData()
{
RecipientList = CreateRecipientList();
SenderList = CreateSenderList();
dataTable = new DataTable();
CreateDataTableColumns(dataTable);
}
List<Recipient> CreateRecipientList() => new List<Recipient>() {
new Recipient("Alfreds Futterkiste", "Maria Anders", "Sales Representative",
"Obere Str. 57", "Berlin", "12209", "mariaanders@example.com"),
new Recipient("Ana Trujillo Emparedados y helados", "Ana Trujillo", "Owner",
"Avda. de la Constitucion, 2222", "Mexico D.F.", "5021", "anatrujillo@example.com"),
new Recipient("Antonio Moreno Taqueria", "Antonio Moreno", "Owner",
"Mataderos 2312", "Mexico D.F.", "5023", "antoniomoreno@example.com"),
new Recipient("Around the Horn", "Thomas Hardy", "Sales Representative",
"120 Hanover Sq.", "London", "WA1 1DP", "thomashardy@example.com"),
new Recipient("Berglunds snabbkop", "Christina Berglund", "Order Administrator",
"Berguvsvegen 8", "Lulee", "S-958 22", "christinaberglund@example.com"),
new Recipient("Blauer See Delikatessen", "Hanna Moos", "Sales Representative",
"Forsterstr. 57", "Mannheim", "68306", "hannamoos@example.com"),
new Recipient("Blondel pure et fils", "Frederique Citeaux", "Marketing Manager",
"24 Place Kleber", "Strasbourg", "67000", "frederiqueciteaux@example.com"),
new Recipient("Bolido Comidas preparadas", "Martin Sommer", "Owner",
"C-Araquil, 67", "Madrid", "28023", "martinsommer@example.com"),
new Recipient("Bon app'", "Laurence Lebihan", "Owner", "12, rue des Bouchers",
"Marseille", "13008", "laurencelebihan@example.com")
};
List<Sender> CreateSenderList() => new List<Sender>() {
new Sender("Nancy", "Davolio", "Sales Representative"),
new Sender("Andrew", "Fuller", "Vice President, Sales"),
new Sender("Janet", "Leverling", "Sales Representative"),
new Sender("Margaret", "Peacock", "Sales Representative"),
new Sender("Steven", "Buchanan", "Sales Manager")
};
void CreateDataTableColumns(DataTable dataTable)
{
dataTable.Columns.Add("FirstName", typeof(string));
dataTable.Columns.Add("LastName", typeof(string));
dataTable.Columns.Add("Title", typeof(string));
dataTable.Columns.Add("CompanyName", typeof(string));
dataTable.Columns.Add("ContactName", typeof(string));
dataTable.Columns.Add("ContactTitle", typeof(string));
dataTable.Columns.Add("Address", typeof(string));
dataTable.Columns.Add("City", typeof(string));
dataTable.Columns.Add("PostalCode", typeof(string));
dataTable.Columns.Add("Email", typeof(string));
}
public DataTable GetDataSource(Sender sender, Recipient recipient)
{
dataTable.Rows.Clear();
dataTable.Rows.Add(sender.FirstName,
sender.LastName,
sender.Title,
recipient.CompanyName,
recipient.ContactName,
recipient.ContactTitle,
recipient.Address,
recipient.City,
recipient.PostalCode,
recipient.Email);
return dataTable;
}
}
public class Recipient
{
public Recipient(string companyName, string contactName, string contactTitle,
string address, string city, string postalCode, string email)
{
CompanyName = companyName;
ContactName = contactName;
ContactTitle = contactTitle;
Address = address;
City = city;
PostalCode = postalCode;
Email = email;
}
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string PostalCode { get; set; }
public string Email { get; set; }
}
public class Sender
{
public Sender(string firstName, string lastName, string title)
{
FirstName = firstName;
LastName = lastName;
Title = title;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
public string FullName => $"{FirstName} {LastName}";
}
}