public EntitiesController( IIlaroAdmin admin, Notificator notificator, IRecordsService recordsService, IConfiguration configuration) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (notificator == null) { throw new ArgumentNullException(nameof(notificator)); } if (recordsService == null) { throw new ArgumentException(nameof(recordsService)); } if (configuration == null) { throw new ArgumentException(nameof(configuration)); } _admin = admin; _notificator = notificator; _recordsService = recordsService; _configuration = configuration; }
public RecordsHierarchySource(IIlaroAdmin admin) { if (admin == null) throw new ArgumentNullException(nameof(admin)); _admin = admin; }
public EntityController( IIlaroAdmin admin, Notificator notificator, IEntityService entityService, IFetchingRecords source, IFetchingRecordsHierarchy hierarchySource) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (notificator == null) { throw new ArgumentNullException(nameof(notificator)); } if (entityService == null) { throw new ArgumentNullException(nameof(entityService)); } if (source == null) { throw new ArgumentNullException(nameof(source)); } if (hierarchySource == null) { throw new ArgumentNullException(nameof(hierarchySource)); } _admin = admin; _notificator = notificator; _entityService = entityService; _source = source; _hierarchySource = hierarchySource; }
private void SetForeignKeysReferences(Entity entity, IIlaroAdmin admin) { foreach (var property in entity.Properties.Where(x => x.IsForeignKey)) { property.ForeignEntity = admin.GetEntity(property.ForeignEntityName); if (property.ReferencePropertyName.IsNullOrEmpty() == false) { property.ReferenceProperty = entity[property.ReferencePropertyName]; if (property.ReferenceProperty != null) { property.ReferenceProperty.IsForeignKey = true; property.ReferenceProperty.ForeignEntity = property.ForeignEntity; property.ReferenceProperty.ReferenceProperty = property; } else if (property.TypeInfo.IsSystemType == false) { property.TypeInfo.OriginalType = property.ForeignEntity == null ? // by default foreign property is int property.TypeInfo.OriginalType = typeof(int) : property.ForeignEntity.Keys.FirstOrDefault().TypeInfo.OriginalType; } } } }
public RecordsUpdater( IIlaroAdmin admin, IExecutingDbCommand executor, IFetchingRecords source, IProvidingUser user) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (source == null) { throw new ArgumentNullException(nameof(source)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } _admin = admin; _executor = executor; _source = source; _user = user; }
public TestBase() { _admin = new IlaroAdmin(); var resolver = A.Fake<IDependencyResolver>(); DependencyResolver.SetResolver(resolver); A.CallTo(() => resolver.GetService(typeof(IIlaroAdmin))) .Returns(_admin); }
public TestBase() { _admin = new IlaroAdmin(); var resolver = A.Fake <IDependencyResolver>(); DependencyResolver.SetResolver(resolver); A.CallTo(() => resolver.GetService(typeof(IIlaroAdmin))) .Returns(_admin); }
public RecordsHierarchySource(IIlaroAdmin admin) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } _admin = admin; }
public RecordsSource(IIlaroAdmin admin, Notificator notificator) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (notificator == null) throw new ArgumentNullException(nameof(notificator)); _admin = admin; _notificator = notificator; }
public DbCommandExecutor(IIlaroAdmin admin, IProvidingUser user) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (user == null) throw new ArgumentNullException(nameof(user)); _admin = admin; _user = user; }
public SharedController(IIlaroAdmin admin, Notificator notificator) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (notificator == null) throw new ArgumentNullException(nameof(notificator)); _admin = admin; _notificator = notificator; }
public RecordsSource(IIlaroAdmin admin, Notificator notificator) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (notificator == null) { throw new ArgumentNullException(nameof(notificator)); } _admin = admin; _notificator = notificator; }
public SharedController(IIlaroAdmin admin, Notificator notificator) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (notificator == null) { throw new ArgumentNullException(nameof(notificator)); } _admin = admin; _notificator = notificator; }
public DbCommandExecutor(IIlaroAdmin admin, IProvidingUser user) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } _admin = admin; _user = user; }
public RecordsService( IIlaroAdmin admin, IFetchingRecords entitiesSource, IFilterFactory filterFactory) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (entitiesSource == null) throw new ArgumentNullException(nameof(entitiesSource)); if (filterFactory == null) throw new ArgumentNullException(nameof(filterFactory)); _admin = admin; _entitiesSource = entitiesSource; _filterFactory = filterFactory; }
public RecordsCreator( IIlaroAdmin admin, IExecutingDbCommand executor, IProvidingUser user) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (executor == null) throw new ArgumentNullException(nameof(executor)); if (user == null) throw new ArgumentNullException(nameof(user)); _admin = admin; _executor = executor; _user = user; }
public GroupController( IIlaroAdmin admin, Notificator notificator, IRecordsService recordsService) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (notificator == null) throw new ArgumentNullException(nameof(notificator)); if (recordsService == null) throw new ArgumentNullException(nameof(recordsService)); _admin = admin; _notificator = notificator; _recordsService = recordsService; }
public EntitiesController( IIlaroAdmin admin, Notificator notificator, IRecordsService recordsService, IConfiguration configuration) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (notificator == null) throw new ArgumentNullException(nameof(notificator)); if (recordsService == null) throw new ArgumentException(nameof(recordsService)); if (configuration == null) throw new ArgumentException(nameof(configuration)); _admin = admin; _notificator = notificator; _recordsService = recordsService; _configuration = configuration; }
public RecordsUpdater( IIlaroAdmin admin, IExecutingDbCommand executor, IFetchingRecords source, IProvidingUser user) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (executor == null) throw new ArgumentNullException(nameof(executor)); if (source == null) throw new ArgumentNullException(nameof(source)); if (user == null) throw new ArgumentNullException(nameof(user)); _admin = admin; _executor = executor; _source = source; _user = user; }
public RecordsService( IIlaroAdmin admin, IFetchingRecords entitiesSource, IFilterFactory filterFactory) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (entitiesSource == null) { throw new ArgumentNullException(nameof(entitiesSource)); } if (filterFactory == null) { throw new ArgumentNullException(nameof(filterFactory)); } _admin = admin; _entitiesSource = entitiesSource; _filterFactory = filterFactory; }
public GroupController( IIlaroAdmin admin, Notificator notificator, IRecordsService recordsService) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (notificator == null) { throw new ArgumentNullException(nameof(notificator)); } if (recordsService == null) { throw new ArgumentNullException(nameof(recordsService)); } _admin = admin; _notificator = notificator; _recordsService = recordsService; }
public RecordsCreator( IIlaroAdmin admin, IExecutingDbCommand executor, IProvidingUser user) { if (admin == null) { throw new ArgumentNullException(nameof(admin)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } _admin = admin; _executor = executor; _user = user; }
public EntityController( IIlaroAdmin admin, Notificator notificator, IEntityService entityService, IFetchingRecords source, IFetchingRecordsHierarchy hierarchySource) { if (admin == null) throw new ArgumentNullException(nameof(admin)); if (notificator == null) throw new ArgumentNullException(nameof(notificator)); if (entityService == null) throw new ArgumentNullException(nameof(entityService)); if (source == null) throw new ArgumentNullException(nameof(source)); if (hierarchySource == null) throw new ArgumentNullException(nameof(hierarchySource)); _admin = admin; _notificator = notificator; _entityService = entityService; _source = source; _hierarchySource = hierarchySource; }
public void CustomizeEntity(Entity entity, IIlaroAdmin admin) { if (entity.IsChangeEntity) { _classCustomizer.AllowEdit = false; _classCustomizer.AllowDelete = false; } entity.SetTableName( _classCustomizer.Table.GetValueOrDefault(entity.Name.Pluralize()), _classCustomizer.Schema); if (_classCustomizer.NameSingular.HasValue()) entity.Verbose.Singular = _classCustomizer.NameSingular; if (_classCustomizer.NamePlural.HasValue()) entity.Verbose.Plural = _classCustomizer.NamePlural; if (_classCustomizer.Group.HasValue()) entity.Verbose.Group = _classCustomizer.Group; entity.RecordDisplayFormat = _classCustomizer.DisplayFormat; entity.SoftDeleteEnabled = _classCustomizer.SoftDeleteEnabled; entity.Links.Display = _classCustomizer.DisplayLink; entity.Links.Edit = _classCustomizer.EditLink; entity.Links.Delete = _classCustomizer.DeleteLink; if (_classCustomizer.AllowEdit.HasValue) entity.AllowEdit = _classCustomizer.AllowEdit.Value; if (_classCustomizer.AllowDelete.HasValue) entity.AllowDelete = _classCustomizer.AllowDelete.Value; if (_classCustomizer.PropertiesGroups.IsNullOrEmpty()) { entity.Groups.Add(new GroupProperties { IsCollapsed = false, //Properties = entity.Properties }); } else { foreach (var group in _classCustomizer.PropertiesGroups) { entity.Groups.Add(new GroupProperties { GroupName = group.Key, IsCollapsed = group.Value, //Properties = entity.Properties.Where(x => x.Group == group.Key) }); } } SetDefaultId(entity); SetDefaultDisplayProperties(entity); SetDefaultSearchProperties(entity); foreach (var customizerPair in _propertyCustomizers) { var propertyCustomizer = customizerPair.Value; var property = entity[customizerPair.Key.Name]; property.IsKey = propertyCustomizer.IsKey.GetValueOrDefault(false); if (propertyCustomizer.IsForeignKey) property.SetForeignKey(propertyCustomizer.ForeignKey); } }
public void CustomizeEntity(Entity entity, IIlaroAdmin admin) { if (entity.IsChangeEntity) { _classCustomizer.AllowEdit = false; _classCustomizer.AllowDelete = false; } entity.SetTableName( _classCustomizer.Table.GetValueOrDefault(entity.Name.Pluralize()), _classCustomizer.Schema); if (_classCustomizer.NameSingular.HasValue()) entity.Verbose.Singular = _classCustomizer.NameSingular; if (_classCustomizer.NamePlural.HasValue()) entity.Verbose.Plural = _classCustomizer.NamePlural; if (_classCustomizer.Group.HasValue()) entity.Verbose.Group = _classCustomizer.Group; entity.RecordDisplayFormat = _classCustomizer.DisplayFormat; entity.SoftDeleteEnabled = _classCustomizer.SoftDeleteEnabled; entity.Links.Display = _classCustomizer.DisplayLink; entity.Links.Edit = _classCustomizer.EditLink; entity.Links.Delete = _classCustomizer.DeleteLink; if (_classCustomizer.AllowEdit.HasValue) entity.AllowEdit = _classCustomizer.AllowEdit.Value; if (_classCustomizer.AllowDelete.HasValue) entity.AllowDelete = _classCustomizer.AllowDelete.Value; entity.ConcurrencyCheckEnabled = _classCustomizer.ConcurrencyCheckEnabled.HasValue ? _classCustomizer.ConcurrencyCheckEnabled.Value : _propertyCustomizers.Any(x => x.Value.IsConcurrencyCheck); if (_classCustomizer.PropertiesGroups.IsNullOrEmpty()) { entity.Groups.Add(new GroupProperties { IsCollapsed = false }); } else { foreach (var group in _classCustomizer.PropertiesGroups) { entity.Groups.Add(new GroupProperties { GroupName = group.Key, IsCollapsed = group.Value }); } } SetDefaultId(entity); SetDefaultSearchProperties(entity); SetDefaultDisplayProperties(entity); if (entity.ConcurrencyCheckEnabled) { SetDefaultConcurrencyCheckProperty(entity); if (_propertyCustomizers.Any(x => x.Value.IsConcurrencyCheck) == false && ((IlaroAdmin)admin).CustomizerHolders.Any(x => x.Key.IsAssignableTo<IEntityChange>()) == false) { throw new InvalidOperationException( $"Concurrency check cannot be enabled for {entity.Name}. " + "Not found any concurrency check property and entity change is not specified."); } } foreach (var customizerPair in _propertyCustomizers) { var propertyCustomizer = customizerPair.Value; var property = entity[customizerPair.Key.Name]; property.IsKey = propertyCustomizer.IsKey.GetValueOrDefault(false); if (propertyCustomizer.IsForeignKey) property.SetForeignKey(propertyCustomizer.ForeignKey); } SetDefaultRecordDisplayFormat(entity); }
public void CustomizeProperties(Entity entity, IIlaroAdmin admin) { SetForeignKeysReferences(entity, admin); foreach (var customizerPair in _propertyCustomizers) { var propertyCustomizer = customizerPair.Value; var property = entity[customizerPair.Key.Name]; if (propertyCustomizer.IsVisible.HasValue) property.IsVisible = propertyCustomizer.IsVisible.Value; if (propertyCustomizer.IsSearchable.HasValue) property.IsSearchable = propertyCustomizer.IsSearchable.Value; if (propertyCustomizer.Column.HasValue()) property.Column = propertyCustomizer.Column; if (propertyCustomizer.DisplayName.HasValue()) property.Display = propertyCustomizer.DisplayName; if (propertyCustomizer.Description.HasValue()) property.Description = propertyCustomizer.Description; property.CascadeOption = propertyCustomizer.CascadeOption .GetValueOrDefault(CascadeOption.Nothing); if (propertyCustomizer.DataType.HasValue) { property.TypeInfo.SourceDataType = propertyCustomizer.SourceDataType; property.TypeInfo.DataType = propertyCustomizer.DataType.Value; property.TypeInfo.EnumType = propertyCustomizer.EnumType; } if (propertyCustomizer.FileOptions != null) property.FileOptions = propertyCustomizer.FileOptions; if (propertyCustomizer.Group != null) property.Group = propertyCustomizer.Group; property.OnCreateDefaultValue = propertyCustomizer.OnCreateDefaultValue; property.OnUpdateDefaultValue = propertyCustomizer.OnUpdateDefaultValue; property.OnDeleteDefaultValue = propertyCustomizer.OnDeleteDefaultValue; property.Format = propertyCustomizer.Format; property.IsRequired = propertyCustomizer.IsRequired ?? !TypeHelpers.IsNullableValueType(property.TypeInfo.OriginalType); if (propertyCustomizer.Validators.IsNullOrEmpty() == false) property.Validators = propertyCustomizer.Validators.ToList(); property.IsCreatable = propertyCustomizer.IsCreatable; property.IsTimestamp = propertyCustomizer.IsTimestamp; property.IsConcurrencyCheck = propertyCustomizer.IsConcurrencyCheck; property.DefaultOrder = propertyCustomizer.DefaultOrder; property.DefaultFilter = propertyCustomizer.DefaultFilter; property.IsManyToMany = propertyCustomizer.IsManyToMany; if (propertyCustomizer.IsFilterable.HasValue) property.IsFilterable = propertyCustomizer.IsFilterable.Value; else property.IsFilterable = IsFilterable(property); if (propertyCustomizer.DisplayTemplate.IsNullOrEmpty() == false) { property.Template.Display = propertyCustomizer.DisplayTemplate; } else { property.Template.Display = TemplateUtil.GetDisplayTemplate(property.TypeInfo, property.IsForeignKey); } if (propertyCustomizer.EditorTemplate.IsNullOrEmpty() == false) { property.Template.Editor = propertyCustomizer.EditorTemplate; } else { property.Template.Editor = TemplateUtil.GetEditorTemplate(property.TypeInfo, property.IsForeignKey); } } SetDefaultOrderProperty(entity); if (entity.SoftDeleteEnabled && entity.Properties.All(x => x.OnDeleteDefaultValue == null)) { throw new InvalidOperationException("When soft delete for entity is enabled some of the property must have delete default value"); } }
public void CustomizeEntity(Entity entity, IIlaroAdmin admin) { if (entity.IsChangeEntity) { _classCustomizer.AllowEdit = false; _classCustomizer.AllowDelete = false; } entity.SetTableName( _classCustomizer.Table.GetValueOrDefault(entity.Name.Pluralize()), _classCustomizer.Schema); if (_classCustomizer.NameSingular.HasValue()) { entity.Verbose.Singular = _classCustomizer.NameSingular; } if (_classCustomizer.NamePlural.HasValue()) { entity.Verbose.Plural = _classCustomizer.NamePlural; } if (_classCustomizer.Group.HasValue()) { entity.Verbose.Group = _classCustomizer.Group; } entity.RecordDisplayFormat = _classCustomizer.DisplayFormat; entity.SoftDeleteEnabled = _classCustomizer.SoftDeleteEnabled; entity.Links.Display = _classCustomizer.DisplayLink; entity.Links.Edit = _classCustomizer.EditLink; entity.Links.Delete = _classCustomizer.DeleteLink; if (_classCustomizer.AllowEdit.HasValue) { entity.AllowEdit = _classCustomizer.AllowEdit.Value; } if (_classCustomizer.AllowDelete.HasValue) { entity.AllowDelete = _classCustomizer.AllowDelete.Value; } entity.ConcurrencyCheckEnabled = _classCustomizer.ConcurrencyCheckEnabled.HasValue ? _classCustomizer.ConcurrencyCheckEnabled.Value : _propertyCustomizers.Any(x => x.Value.IsConcurrencyCheck); if (_classCustomizer.PropertiesGroups.IsNullOrEmpty()) { entity.Groups.Add(new GroupProperties { IsCollapsed = false }); } else { foreach (var group in _classCustomizer.PropertiesGroups) { entity.Groups.Add(new GroupProperties { GroupName = group.Key, IsCollapsed = group.Value }); } } SetDefaultId(entity); SetDefaultSearchProperties(entity); SetDefaultDisplayProperties(entity); if (entity.ConcurrencyCheckEnabled) { SetDefaultConcurrencyCheckProperty(entity); if (_propertyCustomizers.Any(x => x.Value.IsConcurrencyCheck) == false && ((IlaroAdmin)admin).CustomizerHolders.Any(x => x.Key.IsAssignableTo <IEntityChange>()) == false) { throw new InvalidOperationException( $"Concurrency check cannot be enabled for {entity.Name}. " + "Not found any concurrency check property and entity change is not specified."); } } foreach (var customizerPair in _propertyCustomizers) { var propertyCustomizer = customizerPair.Value; var property = entity[customizerPair.Key.Name]; property.IsKey = propertyCustomizer.IsKey.GetValueOrDefault(false); if (propertyCustomizer.IsForeignKey) { property.SetForeignKey(propertyCustomizer.ForeignKey); } } SetDefaultRecordDisplayFormat(entity); }
public void CustomizeProperties(Entity entity, IIlaroAdmin admin) { SetForeignKeysReferences(entity, admin); foreach (var customizerPair in _propertyCustomizers) { var propertyCustomizer = customizerPair.Value; var property = entity[customizerPair.Key.Name]; if (propertyCustomizer.IsVisible.HasValue) { property.IsVisible = propertyCustomizer.IsVisible.Value; } if (propertyCustomizer.IsSearchable.HasValue) { property.IsSearchable = propertyCustomizer.IsSearchable.Value; } if (propertyCustomizer.Column.HasValue()) { property.Column = propertyCustomizer.Column; } if (propertyCustomizer.DisplayName.HasValue()) { property.Display = propertyCustomizer.DisplayName; } if (propertyCustomizer.Description.HasValue()) { property.Description = propertyCustomizer.Description; } property.CascadeOption = propertyCustomizer.CascadeOption .GetValueOrDefault(CascadeOption.Nothing); if (propertyCustomizer.DataType.HasValue) { property.TypeInfo.SourceDataType = propertyCustomizer.SourceDataType; property.TypeInfo.DataType = propertyCustomizer.DataType.Value; property.TypeInfo.EnumType = propertyCustomizer.EnumType; } if (propertyCustomizer.FileOptions != null) { property.FileOptions = propertyCustomizer.FileOptions; } if (propertyCustomizer.Group != null) { property.Group = propertyCustomizer.Group; } property.OnCreateDefaultValue = propertyCustomizer.OnCreateDefaultValue; property.OnUpdateDefaultValue = propertyCustomizer.OnUpdateDefaultValue; property.OnDeleteDefaultValue = propertyCustomizer.OnDeleteDefaultValue; property.Format = propertyCustomizer.Format; property.IsRequired = propertyCustomizer.IsRequired ?? !TypeHelpers.IsNullableValueType(property.TypeInfo.OriginalType); if (propertyCustomizer.Validators.IsNullOrEmpty() == false) { property.Validators = propertyCustomizer.Validators.ToList(); } property.IsCreatable = propertyCustomizer.IsCreatable; property.IsTimestamp = propertyCustomizer.IsTimestamp; property.IsConcurrencyCheck = propertyCustomizer.IsConcurrencyCheck; property.DefaultOrder = propertyCustomizer.DefaultOrder; property.DefaultFilter = propertyCustomizer.DefaultFilter; property.IsManyToMany = propertyCustomizer.IsManyToMany; if (propertyCustomizer.IsFilterable.HasValue) { property.IsFilterable = propertyCustomizer.IsFilterable.Value; } else { property.IsFilterable = IsFilterable(property); } if (propertyCustomizer.DisplayTemplate.IsNullOrEmpty() == false) { property.Template.Display = propertyCustomizer.DisplayTemplate; } else { property.Template.Display = TemplateUtil.GetDisplayTemplate(property.TypeInfo, property.IsForeignKey); } if (propertyCustomizer.EditorTemplate.IsNullOrEmpty() == false) { property.Template.Editor = propertyCustomizer.EditorTemplate; } else { property.Template.Editor = TemplateUtil.GetEditorTemplate(property.TypeInfo, property.IsForeignKey); } } SetDefaultOrderProperty(entity); if (entity.SoftDeleteEnabled && entity.Properties.All(x => x.OnDeleteDefaultValue == null)) { throw new InvalidOperationException("When soft delete for entity is enabled some of the property must have delete default value"); } }