Пример #1
0
 public void Save()
 {
     if (CanSave())
     {
         Debug.Assert(_model != null, "_model is null!!");
         IsEditing     = false;
         DataViewModel = _viewModelCreator.CreateDataDetailViewModel(_realModel.DataModel);
         _realModel.Save(_saveTempModel);
         Debug.Assert(StateCanChanged != null);
         StateCanChanged(this, new EventArgs());
     }
 }
Пример #2
0
        /// <summary>
        /// Исключения:
        ///   System.ArgumentNullException:
        ///     Параметр model имеет значение null.
        /// </summary>
        /// <param name="model"></param>
        public DetailItemViewModel(IItemModelAdapter <DataModelType> model,
                                   IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator,
                                   IItemModelAdapterCreator <DataModelType> itemModelCreator)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model can't be null");
            }
            if (viewModelCreator == null)
            {
                throw new ArgumentNullException("viewModelCreator can't be null");
            }
            if (itemModelCreator == null)
            {
                throw new ArgumentNullException("itemModelCreator can't be null");
            }

            _model          = model;
            _model.Updated += OnUpdate;
            UpdateCommand   = new UpdateItemCommand <DataModelType, DataDetailViewModelType>(this);
            EditCommand     = new EditItemCommand <DataModelType, DataDetailViewModelType>(this);
            SaveCommand     = new SaveItemCommand <DataModelType, DataDetailViewModelType>(this);

            Debug.Assert(_model.DataModel != null);
            _viewModelCreator = viewModelCreator;
            _itemModelCreator = itemModelCreator;
            DataViewModel     = _viewModelCreator.CreateDataDetailViewModel(_model.DataModel);
        }