/// <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(); }
/// <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(); } }