|
|
|
@ -37,23 +37,22 @@ namespace Notus_Persistance
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(DatabaseDataFilePath))
|
|
|
|
|
{
|
|
|
|
|
Database database1;
|
|
|
|
|
using (FileStream fileStream = File.OpenRead(DatabaseDataFilePath))
|
|
|
|
|
{
|
|
|
|
|
Database? database = (Database?)DatabasejsonSerializer.ReadObject(fileStream);
|
|
|
|
|
if (database == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Failed to load database. The loaded object is null.");
|
|
|
|
|
throw new FileException("Failed to load database. The loaded object is null.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return database1 = database;
|
|
|
|
|
return database;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("No data file found.");
|
|
|
|
|
throw new FileException("No data file found.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,7 +81,7 @@ namespace Notus_Persistance
|
|
|
|
|
User? user = (User?)UserjsonSerializer.ReadObject(fileStream);
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Failed to load database. The loaded object is null.");
|
|
|
|
|
throw new FileException("Failed to load database. The loaded object is null.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -92,7 +91,7 @@ namespace Notus_Persistance
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("No userfile find");
|
|
|
|
|
throw new FileException("No userfile find");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|