Пример #1
0
        public SkierDetailViewModel(ISkierViewModel parent)
        {
            this.Parent              = parent ?? throw new ArgumentNullException();
            this.CountryCodes        = new ObservableCollection <string>();
            this.notificationService = App.Container.Resolve <INotificationService>();
            this.locationLogic       = App.Container.Resolve <ILocationLogic>();

            this.SaveCommandViewModel = new CommandViewModel(
                "Save",
                "Save skier",
                async() => await this.Parent.SaveAsync(),
                () => !this.Parent.Edit?.HasErrors ?? false);

            this.SaveCommandViewModel.OnSuccess += () => this.notificationService.ShowMessage("Saved successfully");
            this.SaveCommandViewModel.OnFailure += (ex) => this.notificationService.ShowMessage("Save failed");

            this.RemoveCommandViewModel = new CommandViewModel(
                "Remove",
                "Remove skier",
                async() => await this.Parent.RemoveAsync(),
                withStyle: ButtonStyle.Flat);

            this.RemoveCommandViewModel.OnSuccess += () => this.notificationService.ShowMessage("Removed successfully");
            this.RemoveCommandViewModel.OnFailure += (ex) => this.notificationService.ShowMessage("Remove failed");
        }
Пример #2
0
 public SkierListViewModel(ISkierViewModel parent)
 {
     this.Parent     = parent ?? throw new ArgumentNullException();
     this.NewCommand = new AsyncDelegateCommand(this.Parent.NewAsync);
 }