public static void AssertDomainModelBaseIsSavedAndAuditFieldsArePopulated( DomainModelBase actual, string valueName) { Assert.IsNotNull(valueName, "valueName parameter should not be null."); Assert.AreNotEqual <int>(0, actual.Id, String.Format( "Expected object to be saved but {0} Id was zero.", valueName)); AssertIsNotNullOrWhitespace( actual.CreatedBy, String.Format("{0} CreatedBy", valueName)); AssertIsNotNullOrWhitespace( actual.LastModifiedBy, String.Format("{0} LastModifiedBy", valueName)); UnitTestUtility.AssertDateTimeIsRecent( actual.CreatedDate, String.Format("{0} CreatedDate", valueName)); UnitTestUtility.AssertDateTimeIsRecent( actual.LastModifiedDate, String.Format("{0} LastModified", valueName)); }
public virtual ObservableCollection <ItemViewModelBase <TDomainClass> > CreateItemViewModelCollection( DomainModelBase <TDomainClass> domainModel, ViewModelFactoryBase <TDomainClass> factory) { _itemViewModelCollection.Clear(); foreach (TDomainClass obj in domainModel.All) { _itemViewModelCollection.Add(factory.CreateItemViewModel(obj)); } return(_itemViewModelCollection); }
protected virtual void PopulateFieldsFromEntityAfterSave( EntityBase fromValue, DomainModelBase toValue) { if (fromValue == null) { throw new ArgumentNullException(nameof(fromValue), $"{nameof(fromValue)} is null."); } if (toValue == null) { throw new ArgumentNullException(nameof(toValue), $"{nameof(toValue)} is null."); } toValue.Id = fromValue.Id; }
protected void PopulateAuditFieldsBeforeSave(DomainModelBase toValue) { if (toValue == null) { throw new ArgumentNullException(nameof(toValue), $"{nameof(toValue)} is null."); } if (toValue.Id == 0) { toValue.CreatedBy = _UsernameProvider.GetUsername(); toValue.CreatedDate = DateTime.UtcNow; } toValue.LastModifiedBy = _UsernameProvider.GetUsername(); toValue.LastModifiedDate = DateTime.UtcNow; }
protected MasterDetailsViewModelBase(ViewModelFactoryBase <TDomainClass> viewModelFactory, DomainModelBase <TDomainClass> domainModel) { _domainModel = domainModel; _viewModelFactory = viewModelFactory; _masterViewModel = _viewModelFactory.CreateMasterViewModel(); _detailsViewModel = null; _itemViewModelSelected = null; _stateManager = new ViewControlStateManager(); _viewState = ViewControlState.ViewState.Read; SetupViewStateCommands(); SetupViewActionControllers(); }
public static void AssertDomainModelBaseAuditFieldsArePopulated( DomainModelBase actual, string expectedUsername, string valueName) { Assert.IsNotNull(valueName, "valueName parameter should not be null."); AssertDomainModelBaseAuditFieldsArePopulated( actual, valueName); Assert.AreEqual <string>( expectedUsername, actual.CreatedBy, String.Format("{0} CreatedBy", valueName)); Assert.AreEqual <string>( expectedUsername, actual.LastModifiedBy, String.Format("{0} LastModifiedBy", valueName)); }
protected void PopulateFieldsFromEntityAfterSave( DataAccess.Entities.EntityBase fromValue, DomainModelBase toValue) { if (fromValue == null) { throw new ArgumentNullException(nameof(fromValue), $"{nameof(fromValue)} is null."); } if (toValue == null) { throw new ArgumentNullException(nameof(toValue), $"{nameof(toValue)} is null."); } toValue.Id = fromValue.Id; toValue.LastModifiedDate = fromValue.LastModifiedDate; toValue.LastModifiedBy = fromValue.LastModifiedBy; toValue.CreatedDate = fromValue.CreatedDate; toValue.CreatedBy = fromValue.CreatedBy; }
public static void AssertDomainModelBaseAuditFieldsArePopulated( DomainModelBase actual, string valueName) { Assert.IsNotNull(valueName, "valueName parameter should not be null."); AssertIsNotNullOrWhitespace( actual.CreatedBy, String.Format("{0} CreatedBy", valueName)); AssertIsNotNullOrWhitespace( actual.LastModifiedBy, String.Format("{0} LastModifiedBy", valueName)); UnitTestUtility.AssertDateTimeIsRecent( actual.CreatedDate, String.Format("{0} CreatedDate", valueName)); UnitTestUtility.AssertDateTimeIsRecent( actual.LastModifiedDate, String.Format("{0} LastModified", valueName)); }
protected ControllerBase(MasterDetailsViewModelBase <TDomainClass> masterDetailsViewModel, DomainModelBase <TDomainClass> domainModel) { MasterDetailsViewModel = masterDetailsViewModel; DomainModel = domainModel; }
public CreateControllerBase(MasterDetailsViewModelBase <TDomainClass> masterDetailsViewModel, DomainModelBase <TDomainClass> domainModel) : base(masterDetailsViewModel, domainModel) { }
protected virtual void PopulateAuditFieldsBeforeSave(DomainModelBase toValue) { }