StorageServer/IO/DatabaseFactory.cs
2024-03-24 10:29:56 +09:00

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);
}
}