diff options
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index 65085fd..d371c84 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -46,7 +46,7 @@ public class CrudService<TEntity> : IDisposable where TEntity : class return result; } - public TEntity GetByKey(string key) + public TEntity GetByKey(object key) { var result = _table.Select<TEntity>(_dbConnection, null, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key)); return result.Single(); @@ -58,4 +58,15 @@ public class CrudService<TEntity> : IDisposable where TEntity : class var key = _table.Insert(_dbConnection, insertClauses); return (string)key; } + + public void Update(object key, JsonElement jsonElement) + { + var updateClauses = _jsonHelper.ConvertJsonElementToUpdateClause(jsonElement); + _table.Update(_dbConnection, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key), updateClauses); + } + + public void DeleteByKey(object key) + { + _table.Delete(_dbConnection, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key)); + } } |