Added entry saving support
This commit is contained in:
@@ -8,6 +8,9 @@ public interface ITableManager {
|
||||
public (IEnumerable<object>, int) Search(string searchTerm, int page = 0, int perPage = 20);
|
||||
public int TotalPages(int perPage = 20);
|
||||
public Task DeleteItem(object item);
|
||||
public Task EditItem(object item);
|
||||
public Task AddItem(object item);
|
||||
public Task RevertChanges(object item);
|
||||
|
||||
public string DisplayProperty(object? item, PropertyInfo info, TableConfig? tableConfig);
|
||||
}
|
||||
@@ -37,6 +37,20 @@ internal sealed class TableManager<TModel>(DbContext context, TableConfig config
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task EditItem(object item) {
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task AddItem(object item) {
|
||||
var table = context.Set<TModel>();
|
||||
await table.AddAsync((TModel)item);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task RevertChanges(object item) {
|
||||
await context.Entry((TModel)item).ReloadAsync();
|
||||
}
|
||||
|
||||
private bool ItemSearched(TModel item, string searchTerm) {
|
||||
foreach (var property in config.Properties) {
|
||||
if (!property.Searchable) continue;
|
||||
|
||||
Reference in New Issue
Block a user