internal MainPageViewModel GetMainPageView() { MainPageViewModel model = new MainPageViewModel(); var players = _playeRepository.GetAll().ToList(); model.PlayerViewModels = PlayerViewModel.Convert(players); var dates = players.Select(x => x.ScoreItems.Select(y => y.DateTime)); foreach (var date in dates) { foreach (var dateTime in date) { if (!model.ChartItems.ContainsKey(dateTime)) { model.ChartItems.Add(dateTime, new int[players.Count()][]); } } } for (int i = 0; i < players.Count; i++) { foreach (var playerScoreItem in players[i].ScoreItems.GroupBy(x => x.DateTime)) { model.ChartItems[playerScoreItem.Key][i] = playerScoreItem.Select(x => x.Score).ToArray(); } } return(model); }