Editing an API based data source

Docs

In addition to tight coupling with the database directly you can also use DbNetEditCore as ain interface to update typed objects from an API as a data source. In this example the form control is created with a data source type of List and then given a list of Products passed from the controller as a typed list. Changes including inserts, updates and deletes that can be handled by custom controller actions by posting to custom end-points via a custom onJsonUpdated event handler. In this example the changes are applied directly to a database but you have complete freedom to apply the changes however you want but through an easily generated UI./p>

Razor
                                
                                        
DbNetEditCore ProductsEdit = new DbNetEditCore(DataSourceType.List);
ProductsEdit.AddList(Model.Products);
ProductsEdit.Column(nameof(Product.ProductID)).PrimaryKey();
ProductsEdit.Column(nameof(Product.UnitPrice)).Format("c");
ProductsEdit.Column(nameof(Product.Discontinued)).DataType(typeof(bool));
ProductsEdit.Column(nameof(Product.SupplierID)).Lookup(Model.SupplierLookup);
ProductsEdit.Column(nameof(Product.CategoryID)).Lookup(Model.CategoryLookup);
ProductsEdit.Column(new string[] { nameof(Product.UnitPrice), nameof(Product.ProductName), nameof(Product.CategoryID), nameof(Product.SupplierID), nameof(Product.QuantityPerUnit), nameof(Product.ReorderLevel), nameof(Product.UnitsInStock), nameof(Product.UnitsOnOrder) }).Required();
ProductsEdit.Column(nameof(Product.ProductName)).Browse();
ProductsEdit.Column(nameof(Product.ReorderLevel)).DefaultValue("0");
ProductsEdit.Column(nameof(Product.UnitsInStock)).DefaultValue("0");

ProductsEdit.LayoutColumns = 2;
ProductsEdit.Insert = true;
ProductsEdit.Delete = true;

ProductsEdit.Bind(EventType.onJsonUpdated, "applyJsonChanges");
@ProductsEdit.Render()