/// <summary> /// Initializes a new instance of the <see cref="ItemViewModelBase<T>"/> class. /// </summary> /// <param name="messageBoxService">The message box service.</param> /// <param name="modelManager">Service manage the object model</param> public ItemViewModelBase(IMessageBoxService messageBoxService, IGenericManager <T> modelManager) { // get message box service in order to show message to user if (messageBoxService == null) { throw new ArgumentNullException("messageBoxService"); } this.MessageBoxService = messageBoxService; // do initialization try { if (modelManager == null) { throw new ArgumentNullException("modelManager"); } this._modelManager = modelManager; this.Item = ModelManager.New(); // temporarily not use refresh and edit command //RefreshCommand = new DelegateCommand<object>(o => RefreshItemData(), CanExecuteRefreshCommand); EditItemCommand = new CommandBase <T>(o => this.ExecuteEditItemCommand(), o => true); SaveCommand = new CommandBase <T>(o => this.ExecuteSaveCommand(), o => this.CanExecuteSaveCommand()); CancelCommand = new CommandBase <T>(o => this.ExecuteCancelCommand(), o => true); // start edit item this.EditItemCommand.Execute(null); } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="ViewModelListBase<T>"/> class. /// </summary> /// <param name="messageBoxService">The message box service.</param> /// <param name="uiVisualizerService">The UI service.</param> public ListViewModelBase(IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService, IGenericManager <T> modelManager) { if (messageBoxService == null) { throw new ArgumentNullException("messageBoxService"); } this.MessageBoxService = messageBoxService; try { if (uiVisualizerService == null) { throw new ArgumentNullException("uiVisualizerService"); } this.UIVisualizerService = uiVisualizerService; if (modelManager == null) { throw new ArgumentNullException("modelManager"); } this._modelManager = modelManager; #region Initialize commands this.RefreshCommand = new CommandBase <T>(o => ExecuteRefreshCommand(), o => this.CanExecuteRefreshCommand(o)); this.NewCommand = new CommandBase <T>(o => this.ExecuteNewCommand(), o => this.CanExecuteNewCommand(o)); this.EditItemCommand = new CommandBase <T>(o => this.ExecuteEditItemCommand(o), o => this.CanExecuteEditItemCommand(o)); this.DeleteCommand = new CommandBase <T>(o => this.ExecuteDeleteCommand(o), o => this.CanExecuteDeleteCommand(o)); //this.ViewCommand = new CommandBase<T>(o => { ViewItemDetail(this.SelectedItem.Id); }, CanExecuteViewCommand); //this.CopyCommand = new CommandBase<T>(o => { CopyItemDetail(this.SelectedItem.Id); }, CanExecuteCopyCommand); //this.DbLinkCommand = new CommandBase<T>(o => { ViewLinkItems(null); }, o => { return SelectedItem != null; }); this.SelectItemCommand = new CommandBase <T>(o => this.ExecuteSelectItemCommand(o), o => this.CanExecuteSelectItemCommand(o)); #endregion // sets the default value for some status fields isRefreshing = false; //Mediator.Instance.Register(this); Mediator.Instance.RegisterHandler <T>("Updated" + typeof(T).Name + "Successfully", HandleReceivedMessage); Mediator.Instance.RegisterHandler <T>("Created" + typeof(T).Name + "Successfully", HandleReceivedMessage); // get list this.Items = new System.Collections.ObjectModel.ObservableCollection <T>(GetItems()); } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }
public GenericApiController(IGenericManager <T> genericManager) { manager = genericManager; }