Ejemplo n.º 1
0
        private void AddFootballer()
        {
            var footballer = new FootballerModel(TextBoxFirstName, TextBoxLastName, SliderWeight, SliderAge);

            _footballerList.Add(footballer);
            FootballerSerialization.SaveTo(serializationPath, FootballerList.ToList());
        }
Ejemplo n.º 2
0
 public FootballersViewModel()
 {
     if (File.Exists(serializationPath))
     {
         FootballerList = new ObservableCollection <FootballerModel>(FootballerSerialization.LoadFrom(serializationPath));
     }
 }
Ejemplo n.º 3
0
        private void RemoveFootballer()
        {
            var atIndex      = SelectedFootIndex;
            var dialogResult = MessageBox.Show($"Czy na pewno usunąć{Environment.NewLine}obiekt \"{FootballerList[atIndex]}\"?", "Usuń", MessageBoxButton.YesNo);

            if (dialogResult == MessageBoxResult.Yes)
            {
                SelectedFootIndex = -1;
                FootballerList.RemoveAt(atIndex);
                FootballerSerialization.SaveTo(serializationPath, FootballerList.ToList());
            }
        }
Ejemplo n.º 4
0
        private void EditFootballer()
        {
            var footballer   = new FootballerModel(TextBoxFirstName, TextBoxLastName, SliderWeight, SliderAge);
            var dialogResult = MessageBox.Show($"Czy na pewno chcesz zmienić dane{Environment.NewLine}obiektu \"{FootballerList[SelectedFootIndex]}\"?", "Edytuj", MessageBoxButton.YesNo);

            if (dialogResult == MessageBoxResult.Yes)
            {
                FootballerList.Insert(SelectedFootIndex, footballer);
                SelectedFootIndex -= 1;
                FootballerList.RemoveAt(SelectedFootIndex + 1);
                FootballerSerialization.SaveTo(serializationPath, FootballerList.ToList());
            }
        }