public bool Delete()
{
if (ReferenceEquals(UserId, null))
{
return true;
}
// Delete the user
ISQLiteConnection conn = null;
try
{
conn = Injection.Kernel.Get<IDatabase>().GetSqliteConnection();
int affected = conn.Execute("DELETE FROM User WHERE UserId = ?", UserId);
if (affected > 0)
{
// Delete associated sessions
Injection.Kernel.Get<ISessionRepository>().DeleteSessionsForUserId((int)UserId);
return Injection.Kernel.Get<IUserRepository>().DeleteFromUserCache(this);
}
return true;
}
catch (Exception e)
{
logger.Error(e);
}
finally
{
Injection.Kernel.Get<IDatabase>().CloseSqliteConnection(conn);
}
return false;
}