Ejemplo n.º 1
0
 public void RemoveRifle(Models.Rifle rifle)
 {
     riflesModel.Delete(rifle);
     NotifyOfPropertyChange(() => Rifles);
     eventAggregator.PublishOnBackgroundThread(new AppEvent
     {
         Type = Constants.RifleRemovedMessage
     });
 }
Ejemplo n.º 2
0
        public void EditRifle(Models.Rifle rifle)
        {
            var editRifleViewModel = new EditRifleViewModel(
                configurationModel,
                cartridgesModel,
                scopesModel,
                rifle);

            if (windowManager.ShowDialog(editRifleViewModel) ?? false)
            {
                Task.Run(() =>
                {
                    IsBusy   = true;
                    BusyText = "Saving rifle changes...";
                    NotifyOfPropertyChange(() => IsBusy);
                    NotifyOfPropertyChange(() => BusyText);

                    editRifleViewModel.Rifle.IsUsingNonListedAmmo  = false;
                    editRifleViewModel.Rifle.IsUsingNonListedScope = false;
                    riflesModel.InsertOrUpdate(editRifleViewModel.Rifle);
                    NotifyOfPropertyChange(() => Rifles);
                    Refresh();

                    eventAggregator.PublishOnBackgroundThread(new AppEvent
                    {
                        Type = Constants.ConfigurationChangedMessage
                    });

                    eventAggregator.PublishOnBackgroundThread(new RifleChangedEvent
                    {
                        ChangedRifle = editRifleViewModel.Rifle
                    });

                    IsBusy = false;
                    NotifyOfPropertyChange(() => IsBusy);
                });
            }
        }