36 lines
802 B
C#
36 lines
802 B
C#
|
namespace StorageServer.IO;
|
||
|
|
||
|
using StorageServer.Models;
|
||
|
|
||
|
public class DatabaseFactory : IDisposable {
|
||
|
private IDatabase database;
|
||
|
|
||
|
public DatabaseFactory(string fileName) {
|
||
|
this.database = new FileDatabase(fileName);
|
||
|
}
|
||
|
|
||
|
public void Dispose() {
|
||
|
this.database.Dispose();
|
||
|
}
|
||
|
|
||
|
public long Create(FileModel model) {
|
||
|
return this.database.Insert<FileModel>(model);
|
||
|
}
|
||
|
|
||
|
public FileModel Read(long id) {
|
||
|
return this.database.Select<FileModel>(id);
|
||
|
}
|
||
|
|
||
|
public IEnumerable<FileModel> ReadAll() {
|
||
|
return this.database.SelectAll<FileModel>();
|
||
|
}
|
||
|
|
||
|
public bool Update(FileModel model) {
|
||
|
return this.database.Update<FileModel>(model);
|
||
|
}
|
||
|
|
||
|
public bool Delete(long id) {
|
||
|
return this.database.Delete(id);
|
||
|
}
|
||
|
}
|