-
Notifications
You must be signed in to change notification settings - Fork 28
/
InvoiceDocumentDataSource.cs
55 lines (48 loc) · 1.6 KB
/
InvoiceDocumentDataSource.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
using System;
using System.Linq;
using QuestPDF.Helpers;
namespace QuestPDF.ExampleInvoice
{
public static class InvoiceDocumentDataSource
{
private static Random Random = new Random();
public static InvoiceModel GetInvoiceDetails()
{
var items = Enumerable
.Range(1, 25)
.Select(_ => GenerateRandomOrderItem())
.ToList();
return new InvoiceModel
{
InvoiceNumber = Random.Next(1_000, 10_000),
IssueDate = DateTime.Now,
DueDate = DateTime.Now + TimeSpan.FromDays(14),
SellerAddress = GenerateRandomAddress(),
CustomerAddress = GenerateRandomAddress(),
Items = items,
Comments = Placeholders.Paragraph()
};
}
private static OrderItem GenerateRandomOrderItem()
{
return new OrderItem
{
Name = Placeholders.Label(),
Price = (decimal) Math.Round(Random.NextDouble() * 100, 2),
Quantity = Random.Next(1, 10)
};
}
private static Address GenerateRandomAddress()
{
return new Address
{
CompanyName = Placeholders.Name(),
Street = Placeholders.Label(),
City = Placeholders.Label(),
State = Placeholders.Label(),
Email = Placeholders.Email(),
Phone = Placeholders.PhoneNumber()
};
}
}
}