public BoolEntityFilter_() { var entity = new Entity(typeof(TestEntity)); _property = entity["IsSpecial"]; _filter = new BoolEntityFilter(_property, "1"); }
public EnumEntityFilter_() { var entity = new Entity(typeof(TestEntity)); _property = entity["Option"]; _filter = new EnumEntityFilter(_property, "0"); }
public ForeignEntityFilter_() { var entity = new Entity(typeof(TestEntity)); _property = entity["Child"]; _filter = new ForeignEntityFilter(_property, "1"); }
public ChangeEntityFilter_() { var entity = new Entity(typeof(TestEntity)); _property = entity["Name"]; _filter = new ChangeEntityFilter(_property, "entity_name"); }
public RecordsSource_GetRecord() { _source = new RecordsSource(_admin, new Notificator()); _admin.RegisterEntity<Product>(); _admin.Initialise(ConnectionStringName); _entity = _admin.GetEntity("Product"); }
public EntitiesChangesModel( Entity entity, PagedRecords pagedRecords, TableInfo tableInfo) : base(entity, pagedRecords, tableInfo) { }
public RecordsSource_GetRecord() { _source = new RecordsSource(new Notificator()); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == "Product"); }
public void complex_types__are_foreign_key(string propertyName) { var entityType = typeof(TestEntity); var entity = new Entity(entityType); var property = entity[propertyName]; Assert.NotNull(property); Assert.True(property.IsForeignKey); }
public void enums__are_not_foreign_key(string propertyName) { var entityType = typeof(TestEntity); var entity = new Entity(entityType); var property = entity[propertyName]; Assert.NotNull(property); Assert.False(property.IsForeignKey); }
public void collections_of_simple_types_without_foreign_attribute__are_not_foreign_key(string propertyName) { var entityType = typeof(TestEntity); var entity = new Entity(entityType); var property = entity[propertyName]; Assert.NotNull(property); Assert.False(property.IsForeignKey); }
public RecordsSource_Searching_String() { DB.Products.Insert(ProductName: "Test"); DB.Products.Insert(ProductName: "Product"); _source = new RecordsSource(_admin, new Notificator()); Entity<Product>.Register().ReadAttributes(); _admin.Initialise(ConnectionStringName); _entity = _admin.GetEntity("Product"); }
public RecordsSource_BoolEntityFilters() { DB.Products.Insert(ProductName: "Product", Discontinued: true); DB.Products.Insert(ProductName: "Product2", Discontinued: false); _source = new RecordsSource(_admin, new Notificator()); Entity<Product>.Register().ReadAttributes(); _admin.Initialise(ConnectionStringName); _entity = _admin.GetEntity("Product"); _property = _entity["Discontinued"]; }
public RecordsSource_Searching_Numeric() { DB.Products.Insert(ProductName: "Test", UnitPrice: 3); DB.Products.Insert(ProductName: "Product", UnitPrice: 4.23); _source = new RecordsSource(_admin, new Notificator()); Entity<Product>.Register().ReadAttributes() .SearchProperties(x => x.UnitPrice); _admin.Initialise(ConnectionStringName); _entity = _admin.GetEntity("Product"); }
public RecordsSource_Ordering() { DB.Products.Insert(ProductName: "Product"); DB.Products.Insert(ProductName: "Product2"); _source = new RecordsSource(new Notificator()); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == "Product"); }
public RecordsSource_Searching_Numeric() { DB.Products.Insert(ProductName: "Test", UnitPrice: 3); DB.Products.Insert(ProductName: "Product", UnitPrice: 4.23); _source = new RecordsSource(new Notificator()); Entity<Product>.Add().SetSearchProperties(x => x.UnitPrice); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == "Product"); }
public RecordsSource_ForeignEntityFilters() { _supplierId = DB.Suppliers.Insert(CompanyName: "Supplier").SupplierID; DB.Products.Insert(ProductName: "Product", SupplierID: _supplierId); DB.Products.Insert(ProductName: "Product2"); _source = new RecordsSource(_admin, new Notificator()); Entity<Product>.Register().ReadAttributes(); _admin.Initialise(ConnectionStringName); _entity = _admin.GetEntity("Product"); _property = _entity["SupplierID"]; }
public RecordsCreator_() { _user = A.Fake<IProvidingUser>(); A.CallTo(() => _user.Current()).Returns("Test"); var executor = new DbCommandExecutor(_user); _creator = new RecordsCreator(executor); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes.FirstOrDefault(x => x.Name == "Product"); }
public RecordsSource_BoolEntityFilters() { DB.Products.Insert(ProductName: "Product", Discontinued: true); DB.Products.Insert(ProductName: "Product2", Discontinued: false); _source = new RecordsSource(new Notificator()); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == "Product"); _property = _entity["Discontinued"]; }
public RecordsUpdater_() { _source = new RecordsSource(new Notificator()); _user = A.Fake<IProvidingUser>(); A.CallTo(() => _user.Current()).Returns("Test"); var executor = new DbCommandExecutor(_user); _updater = new RecordsUpdater(executor, _source); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _productId = DB.Products.Insert(ProductName: "Product").ProductID; _entity = _source.GetEntityWithData(Admin.GetEntity("Product"), _productId.ToString()); }
public RecordsSource_ForeignEntityFilters() { _supplierId = DB.Suppliers.Insert(CompanyName: "Supplier").SupplierID; DB.Products.Insert(ProductName: "Product", SupplierID: _supplierId); DB.Products.Insert(ProductName: "Product2"); _source = new RecordsSource(new Notificator()); Admin.AddEntity<Product>(); Admin.SetForeignKeysReferences(); Admin.ConnectionStringName = ConnectionStringName; _entity = Admin.EntitiesTypes .FirstOrDefault(x => x.Name == "Product"); _property = _entity["SupplierID"]; }
public EntitiesIndexModel( Entity entity, PagedRecords pagedRecords, TableInfo tableInfo, string url) { Data = pagedRecords.Records; Columns = entity.DisplayProperties .Select(x => new Column(x, tableInfo.Order, tableInfo.OrderDirection)).ToList(); Entity = entity; Pager = new PagerInfo(url, tableInfo.PerPage, tableInfo.Page, pagedRecords.TotalItems); Filters = pagedRecords.Filters.Where(x => x.DisplayInUI).ToList(); TableInfo = tableInfo; }
public static IList<PropertyDeleteOption> Merge( Entity entity, IList<PropertyDeleteOption> propertiesDeleteOptions) { var hierarchy = GetHierarchy(entity); foreach (var deleteOption in hierarchy .Where(x => x.DeleteOption == CascadeOption.AskUser)) { deleteOption.DeleteOption = propertiesDeleteOptions .FirstOrDefault(x => x.HierarchyName == deleteOption.HierarchyName) .DeleteOption; } return hierarchy; }
public EntityDeleteModel(Entity entity) { Entity = entity; PropertiesDeleteOptions = entity.Properties .Where(x => x.IsForeignKey && x.DeleteOption == DeleteOption.AskUser) .Select(x => new PropertyDeleteOption { PropertyName = x.ForeignEntity.Name }) .ToList(); }
public void creates_record_with_many_to_one_foreign_property() { var productId = DB.Products.Insert(ProductName: "Product").ProductID; Admin.AddEntity<Category>(); Admin.SetForeignKeysReferences(); _entity = Admin.EntitiesTypes.FirstOrDefault(x => x.Name == "Category"); _entity["CategoryName"].Value.Raw = "Category"; _entity["Products"].Value.Values.Add(productId); _creator.Create(_entity); var categories = (List<dynamic>)DB.Categories.All().ToList(); Assert.Equal(1, categories.Count); var products = (List<dynamic>)DB.Products.All().ToList(); Assert.Equal(1, products.Count); Assert.Equal(categories.First().CategoryID, products.First().CategoryID); }
public static IList<PropertyDeleteOption> GetHierarchy( Entity entity, bool collapsed = false, string hierarchyNamePrefix = null, int level = 0) { if (hierarchyNamePrefix.HasValue()) hierarchyNamePrefix += "-"; var properties = new List<PropertyDeleteOption>(); foreach (var property in entity.Properties .WhereOneToMany()) { var hierarchyName = hierarchyNamePrefix + property.ForeignEntity.Name; var visible = property.CascadeOption == CascadeOption.AskUser || property.CascadeOption == CascadeOption.Delete; properties.Add(new PropertyDeleteOption { EntityName = property.ForeignEntity.Name, HierarchyName = hierarchyName, DeleteOption = property.CascadeOption, ShowOptions = property.CascadeOption == CascadeOption.AskUser, Collapsed = collapsed, Level = level, Visible = visible }); if (visible) { properties.AddRange(GetHierarchy( property.ForeignEntity, collapsed ? true : property.CascadeOption != CascadeOption.Delete, hierarchyName, ++level)); } } return properties; }
public bool Validate(Entity entity) { var isValid = true; foreach (var property in entity.Properties.Where(x => x.TypeInfo.DataType == DataType.File)) { var file = (HttpPostedFile)property.Value.Raw; var result = FileUpload.Validate( file, property.ImageOptions.MaxFileSize, property.ImageOptions.AllowedFileExtensions, !property.IsRequired); if (result != FileUploadValidationResult.Valid) { isValid = false; // TODO: more complex validation message //modelState.AddModelError(property.Name, IlaroAdminResources.UnvalidFile); } } foreach (var property in entity.Properties.Where(x => x.TypeInfo.DataType != DataType.File)) { foreach (var validator in property.ValidationAttributes) { try { validator.Validate(property.Value.Raw, property.Name); } catch (ValidationException exc) { isValid = false; //modelState.AddModelError(property.Name, exc.Message); } } } return isValid; }
public void simple_types_marked_with_foreign_attribute__are_foreign_key(string propertyName) { var entityType = typeof(TestEntity); var entity = new Entity(entityType); var property = entity[propertyName]; Assert.NotNull(property); Assert.True(property.IsForeignKey); }
public Property_DetermineForeignKey() { Entity<TestEntity>.Register().ReadAttributes(); _admin.Initialise(); _entity = _admin.GetEntity<TestEntity>(); }
public EntityRecord(Entity entity) { Entity = entity; }
private void register_default_entities() { Entity<Product>.Register().ReadAttributes(); Entity<Category>.Register().ReadAttributes(); _admin.Initialise(ConnectionStringName); _productEntity = _admin.GetEntity<Product>(); }