<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventMaster._Helper;
using EventMaster.Participant;
using EventMaster.Storage;
using EventMaster.Storage.Model;

namespace EventMaster.CourseRegistration
{
    public class CourseRegistrationViewModel : INotifyPropertyChanged
    {
        public CourseRegistrationViewModel()
        {
            AllPeriods = new BindingList<IdNameHelper>(Workspace.CurrentData.CoursePeriods.Select(x => new IdNameHelper() { Id = x.Id, Name = x.PeriodName }).OrderBy(x => x.Name).ToList());
            ParticipantsByPeriod = new BindingList<ParticipantViewModel>();

        }

        public List<IdNameHelper> AllCourses
        {
            get
            {
                var list = Workspace.CurrentData.Courses.Where(x => x.PeriodeId == this.PeriodeId).OrderBy(x => x.CourseNumber).ThenBy(x => x.Name).Select(x =>
                {
                    var courseAlreadyFull = Workspace.CurrentData.CourseParticipants.Count(c => c.CourseId == x.Id) >= x.MaxNumberOfParticipants;
                    return new IdNameHelper { Id = x.Id, Name = $"{ (courseAlreadyFull ? "Ausgebucht: " : string.Empty) }{x.CourseNumber} - {x.Name}" };
                }).ToList();
                list.Insert(0, IdNameHelper.Empty);
                return list;
            }
        }

        public string Course1Id { get; set; }
        public string Course2Id { get; set; }
        public string Course3Id { get; set; }
        public string CourseReplaceId { get; set; }
        public string CourseInputId { get; set; }

        private string periodeId;
        private int selectedIndex;
        private ParticipantViewModel selectedParticipant;

        public event PropertyChangedEventHandler PropertyChanged;

        public BindingList<IdNameHelper> AllPeriods { get; }
        public BindingList<ParticipantViewModel> ParticipantsByPeriod { get; private set; }
        public string PeriodeId
        {
            get => periodeId;
            set
            {
                periodeId = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeId)));
                ReloadParticipants();
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AllCourses)));
            }
        }

        private void ReloadParticipants()
        {<commit_msg>Update CourseRegistrationViewModel.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventMaster._Helper;
using EventMaster.Participant;
using EventMaster.Storage;
using EventMaster.Storage.Model;

namespace EventMaster.CourseRegistration
{
    public class CourseRegistrationViewModel : INotifyPropertyChanged
    {
        public CourseRegistrationViewModel()
        {
            AllPeriods = new BindingList<IdNameHelper>(Workspace.CurrentData.CoursePeriods.Select(x => new IdNameHelper() { Id = x.Id, Name = x.PeriodName }).OrderBy(x => x.Name).ToList());
            ParticipantsByPeriod = new BindingList<ParticipantViewModel>();

        }

        public List<IdNameHelper> AllCourses
        {
            get
            {
                var list = Workspace.CurrentData.Courses.Where(x => x.PeriodeId == this.PeriodeId).OrderBy(x => x.CourseNumber).ThenBy(x => x.Name).Select(x =>
                {
                    var courseAlreadyFull = Workspace.CurrentData.CourseParticipants.Count(c => c.CourseId == x.Id) >= x.MaxNumberOfParticipants;
                    return new IdNameHelper { Id = x.Id, Name = $"{ (courseAlreadyFull ? "Ausgebucht: " : string.Empty) }{x.CourseNumber} - {x.Name}" };
                }).ToList();
                list.Insert(0, IdNameHelper.Empty);
                return list;
            }
        }

        public string Course1Id { get; set; }
        public string Course2Id { get; set; }
        public string Course3Id { get; set; }
        public string CourseReplaceId { get; set; }
        public string CourseInputId { get; set; }

        private string periodeId;
        private int selectedIndex;
        private ParticipantViewModel selectedParticipant;

        public event PropertyChangedEventHandler PropertyChanged;

        public BindingList<IdNameHelper> AllPeriods { get; }
        public BindingList<ParticipantViewModel> ParticipantsByPeriod { get; private set; }
        public string PeriodeId
        {
            get { return periodeId; }
            set
            {
                periodeId = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PeriodeId)));
                ReloadParticipants();
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AllCourses)));
            }
        }

        private void ReloadParticipants()
        {
{'fraction_non_alphanumeric': 0.09337349397590361, 'fraction_numerical': 0.001606425702811245, 'mean_word_length': 2.409308692676249, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '139272', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1259, 'n_words': 284}