private void ReloadResultList()
        {
            if (File.Exists(RESULT_FILE_PATH))
            {
                var lines        = File.ReadAllLines(RESULT_FILE_PATH);
                var participants = new List <Participant>();

                foreach (var line in lines)
                {
                    var parts = line.Split(';');
                    participants.Add(new Participant
                    {
                        Name   = parts[0],
                        Points = int.Parse(parts[1]),
                        Email  = parts[2]
                    });
                }

                AllParticipants.Clear();
                AllParticipants = participants.OrderByDescending(p => p.Points).ToList();

                ParticipantsTop10.Clear();
                var top10       = AllParticipants.Take(10);
                var rankCounter = 1;
                foreach (var player in top10)
                {
                    player.Name = player.Name.ToUpper();
                    player.Rank = rankCounter;
                    ParticipantsTop10.Add(player);
                    rankCounter++;
                }
            }
        }
示例#2
0
        public ViewAnalogousVM CollectExistingAnalogousReactions()
        {
            var               mainViewModel   = ((MainWindow)(App.Current.MainWindow)).DataContext as MainVM;
            List <RsnVM>      tanRsns         = new List <RsnVM>();
            List <ReactionVM> tanReactions    = new List <ReactionVM>();
            var               tanParticipants = new List <ReactionParticipantVM>();

            AnalogousReactions.Clear();
            AllParticipants.Clear();
            ReactionParticipants.Clear();
            try
            {
                var analogousReactions = mainViewModel.TanVM.Reactions.Where(r => r.AnalogousVMId == SelectedMasterReaction.Id);
                foreach (var existingAnalogousReaction in analogousReactions)
                {
                    AnalogousReactions.Add(existingAnalogousReaction);
                    AllParticipants.AddRange(mainViewModel.TanVM.ReactionParticipants.Where(rp => rp.ReactionVM.Id == existingAnalogousReaction.Id));
                    ReactionParticipants.AddRange(mainViewModel.TanVM.ReactionParticipants.Where(rp => rp.ReactionVM.Id == existingAnalogousReaction.Id));
                    foreach (var rsn in (mainViewModel.TanVM.Rsns.Where(rsn => rsn.Reaction.Id == existingAnalogousReaction.Id)))
                    {
                        Rsns.Add(rsn);
                    }
                }
            }
            catch (Exception ex)
            {
                AppErrorBox.ShowErrorMessage("Error while collecting analogous reactions", ex.Message);
            }
            return(this);
        }