using System; using System.Collections.Generic; using System.Collections.ObjectModel; using ApiLol.DTO; using Model; namespace ApiLol.Mapping { public static class CharacteristicMapper { public static IEnumerable ToDto(this ReadOnlyDictionary dico) { if (dico == null) { throw new ArgumentNullException(); } IEnumerable characteristicDTOs = new List(); foreach(var item in dico) { characteristicDTOs = characteristicDTOs.Append(new CharacteristicDTO() { Name = item.Key, Val = item.Value }); } return characteristicDTOs; } public static ReadOnlyDictionary ToDto(this IEnumerable characs) { if (characs == null) { throw new ArgumentNullException(); } Dictionary dico = new Dictionary(); foreach (CharacteristicDTO c in characs) { dico.Add(c.Name, c.Val); } return new ReadOnlyDictionary(dico); } } }