-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDictionaryCreator.cs
127 lines (114 loc) · 4.98 KB
/
DictionaryCreator.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
using System.Collections.Generic;
using System.Linq;
namespace Samples.Logic.Emails.Tools
{
internal class DictionaryCreator
{
public static Dictionary<string, object> GetAgent(Agent agent)
{
const string prefix = "Agent";
return new Dictionary<string, object>
{
{$"{prefix}.LastName", agent.LastName},
{$"{prefix}.FirstName", agent.FirstName},
{$"{prefix}.Name", agent.Name},
{$"{prefix}.Email", agent.Email},
{$"{prefix}.Mobile", agent.Mobile},
{$"{prefix}.NationalRegisterIdNumber", agent.NationalRegisterIdNumber},
{$"{prefix}.BadgeNumber", agent.BadgeNumber},
};
}
public static Dictionary<string, object> GetFirm(Firm firm)
{
const string prefix = "Firm";
return new Dictionary<string, object>
{
{$"{prefix}.Name", firm.Name},
{$"{prefix}.Address", firm.Address},
{$"{prefix}.PostalCode", firm.PostalCode},
{$"{prefix}.City", firm.City},
{$"{prefix}.Responsible", firm.Responsible},
{$"{prefix}.Email", firm.Email},
{$"{prefix}.Phone", firm.Phone},
{$"{prefix}.UserName", firm.UserName},
};
}
public static Dictionary<string, object> GetRoom(Room room)
{
const string prefix = "Room";
return new Dictionary<string, object>
{
{$"{prefix}.Code", room.Code},
{$"{prefix}.Type", room.Type},
{$"{prefix}.Zone", room.Zone},
{$"{prefix}.SubZone", room.SubZone},
{$"{prefix}.Address", room.Address},
{$"{prefix}.PostalCode", room.PostalCode},
{$"{prefix}.City", room.City},
{$"{prefix}.Comments", room.Comments},
{$"{prefix}.HasBadgeReader", room.HasBadgeReader},
{$"{prefix}.IsKeyRequired", room.IsKeyRequired ?? false}
};
}
public static Dictionary<string, object> GetRoomAccess(RoomAccess roomAccess)
{
const string prefix = "RoomAccess";
return new Dictionary<string, object>
{
{$"{prefix}.Justification", roomAccess.Justification},
{$"{prefix}.RefusalReason", roomAccess.RefusalReason},
{$"{prefix}.AccessStatus", roomAccess.AccessStatus}
};
}
public static Dictionary<string, object> GetIntervention(Intervention intervention)
{
const string prefix = "Intervention";
return new Dictionary<string, object>
{
{$"{prefix}.Id", intervention.Id},
{$"{prefix}.FunctionalId", intervention.FunctionalId},
{$"{prefix}.Type", intervention.Type},
{$"{prefix}.Comment", intervention.Comment},
{$"{prefix}.RefusalReason", intervention.RefusalReason},
{$"{prefix}.StartDate", intervention.StartDate.AsDdMmmYyyySpaced()},
{$"{prefix}.StartTime", intervention.StartTime.AsHhMmWithColon()},
{$"{prefix}.EndDate", intervention.EndDate.AsDdMmmYyyySpaced()},
{$"{prefix}.EndTime", intervention.EndTime.AsHhMmWithColon()}
};
}
public static Dictionary<string, object> GetAgentAndFirm(Agent agent)
{
return new List<Dictionary<string, object>>
{
GetAgent(agent),
GetFirm(agent.Firm)
}
.SelectMany(dict => dict)
.ToDictionary(pair => pair.Key, pair => pair.Value);
}
public static Dictionary<string, object> GetInterventionRoomAndFirm(Intervention intervention)
{
return new List<Dictionary<string, object>>
{
GetIntervention(intervention),
GetRoom(intervention.RoomAccess.Room),
GetFirm(intervention.Agent.Firm),
}
.SelectMany(dict => dict)
.ToDictionary(pair => pair.Key, pair => pair.Value);
}
public static Dictionary<string, object> GetInterventionRoomAccessRoomAgentAndFirm(Intervention intervention)
{
return new List<Dictionary<string, object>>
{
GetIntervention(intervention),
GetRoomAccess(intervention.RoomAccess),
GetRoom(intervention.RoomAccess.Room),
GetAgent(intervention.Agent),
GetFirm(intervention.Agent.Firm)
}
.SelectMany(dict => dict)
.ToDictionary(pair => pair.Key, pair => pair.Value);
}
}
}