示例#1
0
        /// <summary>
        /// Adds the record to view model.
        /// </summary>
        /// <param name="newRecord">The new record.</param>
        private void AddRecordToViewModel(T newRecord)
        {
            ViewModels.Add(newRecord);

            ValidationHelper.AddSubViewModelHelpers(new IHaveValidationViewModelHelper[] { newRecord });
            newRecord.ValidationHelper.PageIsValidChanged += ResetPageIsValid();

            RecordAddedOrDeleted?.Invoke();
        }
示例#2
0
        /// <summary>
        /// Deletes the record.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        public void DeleteRecord(object viewModel)
        {
            if (ViewModels.IsNotAnEmptyList() && ViewModels.Contains(viewModel))
            {
                if (viewModel is IHaveValidationViewModelHelper viewModelAsHaveValidationViewModelHelper)
                {
                    ValidationHelper.RemoveSubViewModelHelpers(new[] { viewModelAsHaveValidationViewModelHelper });
                    viewModelAsHaveValidationViewModelHelper.ValidationHelper.PageIsValidChanged -= ResetPageIsValid();
                }

                ViewModels.Remove(viewModel);

                RecordAddedOrDeleted?.Invoke();
            }
        }