-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMockDataSource.cs
149 lines (122 loc) · 5.99 KB
/
MockDataSource.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
using Newtonsoft.Json;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace ResumePDF
{
internal static class MockDataSource
{
private static readonly Random random = new Random();
public static InvoiceModel GetInvoiceDetails()
{
var items = Enumerable
.Range(0, 60)
.Select(i => GenerateRandomOrderItem())
.ToList();
return new InvoiceModel
{
InvoiceNumber = random.Next(1_000, 10_000),
IssueDate = DateTime.Now,
DueDate = DateTime.Now + TimeSpan.FromDays(12),
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, 20)
};
}
private static Address GenerateRandomAddress() => new Address
{
CompanyName = Placeholders.Name(),
Street = Placeholders.Label(),
City = Placeholders.Label(),
State = Placeholders.Label(),
Email = Placeholders.Email(),
Phone = Placeholders.PhoneNumber()
};
}
internal static class DataSource
{
public static IComponent LeftHeader
= Utils.JsonToComponent(Utils.ReturnFirstFile(@"Data\HeaderLeft\", "*.json"));
//= Utils.JsonToComponent("Data/HeaderLeft/Brief.json");
public static IComponent RightHeader
= Utils.JsonToComponent(Utils.ReturnFirstFile(@"Data\HeaderRight\", "*.json"));
public static IEnumerable<(string Title, IComponent component)> ReadLeftContent()
{
string[] files = Directory.GetFiles(@"Data\ContentLeft\", "*.json");
Array.Sort(files);
foreach (var file in files)
{
//add component to collection if it is not null
if (Utils.JsonToComponent(file) is IComponent component && component is not null)
{
//Console.WriteLine("Component Null check: " + (component == null));
Console.WriteLine("Component Null check is: " + (component is null));
var JsonName = file.BetweenStrings("-", ".json");
Console.WriteLine("Left Json Name : " + JsonName);
yield return (JsonName, component);
}
else
{
Console.WriteLine("We got a wrong format file on the left side");
}
}
}
public static IEnumerable<(string Title, IComponent component)> ReadRightContent()
{
string[] files = Directory.GetFiles(@"Data\ContentRight\", "*.json");
Array.Sort(files);
foreach (var file in files)
{
//add component to collection if it is not null
if (Utils.JsonToComponent(file) is IComponent component && component is not null)
{
//Console.WriteLine("Right Null check: " + (component == null));
Console.WriteLine("Right Null check is: " + (component is null));
var JsonName = file.BetweenStrings("-", ".json");
Console.WriteLine("Right Json Name : " + JsonName);
yield return (JsonName, component);
}
else
{
Console.WriteLine("We got a wrong format file on the right side");
}
}
}
//private static BulletModelSimple? Brief = Utils.ReadJson<BulletModelSimple>("Data/Brief.json");
//public static BulletSimpleComponent BriefComponent = new BulletSimpleComponent() { SimpleBulletModel = Brief };
//private static BulletsModel? Education = Utils.ReadJson<BulletsModel>("Data/ContentLeft/1-Education.json");
//public static BulletComponent[]? EducationComponent
// => Education?.Select(model => new BulletComponent() { bulletModel = model }).ToArray();
//private static BulletModel[]? WorkExperience = Utils.ReadJson<BulletModel[]>("Data/WorkExperience.json");
//public static BulletComponent[]? WorkExperienceComponent
// => WorkExperience?.Select(model => new BulletComponent() { bulletModel = model }).ToArray();
//private static ContactModel[]? Contacts = Utils.ReadJson<ContactModel[]>("Data/Contacts.json");
//public static ContactComponent ContactsComponent = new() { contactItems = Contacts };
////public static BulletModel[]? WorkExperience => JsonSerializer.Deserialize<BulletModel[]>("WorkExperience.json");
//private static HighlightModel? Skills = Utils.ReadJson<HighlightModel>("Data/Skills.json");
//public static HighlightedItemsComponent SkillsComponent = new() { highlightItems = Skills };
//private static HighlightModel? Interests = Utils.ReadJson<HighlightModel>("Data/Interests.json");
//public static HighlightedItemsComponent InterestsComponent = new() { highlightItems = Interests };
//private static ListModel? Certificates = Utils.ReadJson<ListModel>("Data/Certificates.json");
//public static BasicListComponent CertificatesComponent = new() { BasicList = Certificates };
//private static ListModel? Projects = Utils.ReadJson<ListModel>("Data/Projects.json");
//public static BasicListComponent ProjectsComponent = new() { BasicList = Projects };
//static string fileName = ;
}
}