using System.Collections.Generic;
public class ExternalStockAllocation
public int ExternalSoftAllocationCount {get;set;}
public DateTimeOffset LastUpdatedTimeUTC {get;set;}
public class StockReservation
public string WarehouseCode {get;set;}
public string PartNumber {get;set;}
public decimal Quantity {get;set;}
public static Dictionary<string,StockReservation> Convert(List<Dictionary<string,Dictionary<string,ExternalStockAllocation>>> softAllocations)
var result = new Dictionary<string,StockReservation>();
foreach (var partNumbers in softAllocations)
foreach (var partNumber in partNumbers.Keys)
foreach (var warehouse in partNumbers[partNumber].Keys)
result.Add(string.Join(string.Empty, warehouse, partNumber), new StockReservation()
Quantity = partNumbers[partNumber][warehouse].ExternalSoftAllocationCount,
WarehouseCode = warehouse
public static void Main()
var reservations = new Dictionary<string,StockReservation>();
var softAllocations = new List<Dictionary<string,Dictionary<string,ExternalStockAllocation>>>();
softAllocations.Add(new Dictionary<string,Dictionary<string,ExternalStockAllocation>>()
{ "AVA45380", new Dictionary<string,ExternalStockAllocation>()
{"RCA", new ExternalStockAllocation()
ExternalSoftAllocationCount = 10,
LastUpdatedTimeUTC = DateTime.Now
softAllocations.Add(new Dictionary<string,Dictionary<string,ExternalStockAllocation>>()
{ "NOW00902", new Dictionary<string,ExternalStockAllocation>()
{"EPA", new ExternalStockAllocation()
ExternalSoftAllocationCount = 15,
LastUpdatedTimeUTC = DateTime.Now
{"EIL", new ExternalStockAllocation()
ExternalSoftAllocationCount = 20,
LastUpdatedTimeUTC = DateTime.Now
reservations = Convert(softAllocations);
Console.WriteLine("Results:");
foreach(var key in reservations.Keys)
Console.WriteLine("reservations[" + key + "] Values: "+reservations[key].WarehouseCode +", "+reservations[key].PartNumber +", "+ reservations[key].Quantity);
Console.WriteLine("-- Validation --");
Console.Write("reservations[RCAAVA45380] exists: " + reservations.TryGetValue("RCAAVA45380", out myval));
bool valid = myval.Quantity == 10;
Console.WriteLine(" - reservations[RCAAVA45380].Quantity = 10: " + valid);
Console.Write("reservations[EPANOW00902] exists: " + reservations.TryGetValue("EPANOW00902", out myval));
valid = myval.Quantity == 15;
Console.WriteLine(" - reservations[EPANOW00902].Quantity = 15: " + valid);
Console.Write("reservations[EILNOW00902] exists: " + reservations.TryGetValue("EILNOW00902", out myval));
valid = myval.Quantity == 20;
Console.WriteLine(" - reservations[EILNOW00902].Quantity = 20: " + valid);