Esempio n. 1
0
 public BaseViewModel(INavigationService navService, IEventAggregator eventAggregator, IPurchaseManager purchaseMgr, IMessageSettingsRepository repository)
 {
     this._purchaseManager = purchaseMgr;
     this._eventAggregator = eventAggregator;
     this._navService = navService;
     this._messageRepository = repository;
     this.GoBackCommand = new DelegateCommand(OnGoBack, () => _navService.CanGoBack());
 }
 public MessageSettingsHubPageViewModel(INavigationService navService, IEventAggregator eventAggregator, IPurchaseManager purchaseMgr, IMessageSettingsRepository repository)
     : base(navService, eventAggregator, purchaseMgr, repository)
 {
     this.AddToFavorites = new DelegateCommand(async () =>
     {
         var settingsID = this.Settings.ID;
         await this.MessageRepository.AddMessageSettingsToFavorites(FavoriteMessageSettings.CreateFavoriteMessageSettings(this.Settings));
         var fav = this.MessageRepository.GetFavoriteMessageSettingsFromID(settingsID);
         this.Settings = fav;
         this.FavoriteSettings = fav;
     });
     this.RemoveFromFavorites = new DelegateCommand(async () =>
     {
         var tmpSettings = MessageSettings.Clone(this.Settings);
         await this.MessageRepository.RemoveMessageSettingsFromFavorites(FavoriteMessageSettings.CreateFavoriteMessageSettings(this.Settings));
         this.Settings = tmpSettings;
         SetProperty(ref this._favoriteSettings, null);
     });
     this.ClearAllFavoriteMessages = new DelegateCommand(async () =>
     {
         var tmpSettings = MessageSettings.Clone(this.Settings);
         await this.MessageRepository.ClearFavoriteMessages();
         this.Settings = tmpSettings;
     });
     this.ClearAllOldMessages = new DelegateCommand(async () =>
     {
         var tmpSettings = MessageSettings.Clone(this.Settings);
         await this.MessageRepository.ClearOldMessages();
         this.Settings = tmpSettings;
     });
     this.NewMessage = new DelegateCommand(() => 
         {
             this.Settings = new MessageSettings();
             this.FavoriteSettings = null;
             this.OldSettings = null;
         });
 }