private static DataContracts.DumpData CreateDumpData(List <Town> towns, List <CollectionEvent> events, DataRefreshStatus refreshStatus) { var dumpStatus = new DataContracts.DataRefreshStatus { LatestRefresh = refreshStatus.LatestRefresh, LatestStamp = refreshStatus.LatestStamp, LatestCheck = refreshStatus.LatestCheck, }; var dumpData = new DataContracts.DumpData { RefreshStatus = dumpStatus }; foreach (var town in towns) { var dumpTown = new DataContracts.TownWithStreets { Id = town.Id, Name = town.Name }; dumpData.Towns.Add(dumpTown); foreach (var street in town.Streets) { var dumpStreet = new DataContracts.StreetWithEvents { Id = street.Id, Name = street.Name }; dumpTown.Streets.Add(dumpStreet); foreach (var category in street.Categories) { var dumpCategory = new DataContracts.Category { Id = category.Id, Name = category.Name }; dumpStreet.Categories.Add(dumpCategory); } var eventsInStreet = events.Where(e => e.TownId == town.Id && e.StreetId == street.Id); foreach (var eventInStreet in eventsInStreet) { var dumpEvent = new DataContracts.CollectionEvent { Id = eventInStreet.Id, Category = new DataContracts.Category { Id = eventInStreet.Category.Id, Name = eventInStreet.Category.Name }, Date = eventInStreet.Start, Stamp = eventInStreet.Stamp, }; dumpStreet.Events.Add(dumpEvent); } } } return(dumpData); }