Esempio n. 1
0
        public DataEntryViewModel(IDataService dataService)
        {
            _dataService = dataService;

            #region Commands
            Add = new RelayCommand(async() =>
            {
                CurrentItem.CheckValid();
                if (CurrentItem.HasError())
                {
                    return;
                }

                await CurrentItem.Save();

                init();
            });
            Clear = new RelayCommand(init);
            #endregion

            #region Messages
            Messenger.Default.Register <ItemSelectedMessage>(this, item =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    CurrentItem = new InventurItemViewModel(_dataService, item.SelectedItem);
                });
            });
            #endregion

            if (!this.IsInDesignMode)
            {
                init();
            }
        }