-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (42 loc) · 1.64 KB
/
Program.cs
File metadata and controls
51 lines (42 loc) · 1.64 KB
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
// See https://aka.ms/new-console-template for more information
using Newtonsoft.Json;
namespace ConsoleApp1
{
class Program
{
static IDictionary<string, ShipmentMethod> Map(
List<BasketContentSettings> basketContentSettingsList)
{
var shipmentMethods =
new Dictionary<string, ShipmentMethod>();
foreach (var basketContentSettings in basketContentSettingsList)
{
var shipmentMethod = basketContentSettings.ShipmentMethod;
var paymentMethod = basketContentSettings.PaymentMethod;
if (!shipmentMethods.ContainsKey(shipmentMethod))
{
shipmentMethods[shipmentMethod] = new ShipmentMethod()
{
Method = shipmentMethod,
PaymentMethods = new Dictionary<string, PaymentMethod>()
};
}
shipmentMethods[shipmentMethod].PaymentMethods[paymentMethod] =
new PaymentMethod()
{
Content = basketContentSettings.Content
};
}
return shipmentMethods;
}
static void Main(string[] args)
{
var basketContentSettings =
DataProvider.GetBasketContentSettings();
var shipmentMethods = Map(basketContentSettings);
string res = JsonConvert.SerializeObject(shipmentMethods,
Formatting.Indented);
Console.WriteLine(res);
}
}
}