private static List<RangeItemPairViewModel> Map(IEnumerable<RangeItem> rangeItems) { var result = new List<RangeItemPairViewModel>(); var mapped = MapToRangeItemViewModels(rangeItems); while (mapped.Any()) { var pair = mapped.Take(2).ToArray(); mapped = mapped.Skip(2).ToArray(); var rangeItemPair = new RangeItemPairViewModel { Lefty = pair.First(), Righty = pair.Skip(1).FirstOrDefault() }; result.Add(rangeItemPair); } return result; }
private List<RangeItemPairViewModel> Map(IEnumerable<RangeItem> rangeItems) { var result = new List<RangeItemPairViewModel> { }; var mapped = rangeItems.Select(rangeItem => new RangeItemViewModel { Title = rangeItem.Title }).ToArray(); while (mapped.Any()) { var pair = mapped.Take(2).ToArray(); mapped = mapped.Skip(2).ToArray(); var rangeItemPair = new RangeItemPairViewModel { Lefty = pair.First(), Righty = pair.Skip(1).FirstOrDefault() }; result.Add(rangeItemPair); } return result; }