public static IEnumerable <Account> FindWithAddress(string address) { var cmd = new SqlCommand("SELECT * FROM rohbot.accounts WHERE address=:addr;"); cmd["addr"] = address; return(cmd.Execute().Select(row => new Account(row))); }
public static IEnumerable <LoginToken> FindAll(string username) { var cmd = new SqlCommand("SELECT * FROM rohbot.logintokens WHERE lower(name)=lower(:name);"); cmd["name"] = username; return(cmd.Execute().Select(row => new LoginToken(row))); }
public static IEnumerable <LoginToken> FindAll(long userId) { var cmd = new SqlCommand("SELECT * FROM rohbot.logintokens2 WHERE userid=:userid ORDER BY accessed DESC;"); cmd["userid"] = userId; return(cmd.Execute().Select(row => new LoginToken(row))); }
public static Account Get(string username) { var cmd = new SqlCommand("SELECT * FROM rohbot.accounts WHERE lower(name)=lower(:name);"); cmd["name"] = username; var row = cmd.Execute().FirstOrDefault(); return(row == null ? null : new Account(row)); }
public static LoginToken Find(long userId, string token) { var cmd = new SqlCommand("SELECT * FROM rohbot.logintokens2 WHERE userid=:userid AND token=:token;"); cmd["userid"] = userId; cmd["token"] = token; return(cmd.Execute().Select(row => new LoginToken(row)).SingleOrDefault()); }
public void InvalidateNotificationCache() { var cmd = new SqlCommand(@" SELECT notifications.*, accounts.name, accounts.rooms FROM rohbot.accounts INNER JOIN rohbot.notifications ON (rohbot.accounts.id = rohbot.notifications.userid)"); var newNotifications = cmd.Execute().Select(row => new Notification(row)).ToList(); lock (_sync) { _notifications = newNotifications; } }
public void InvalidateNotificationCache() { var cmd = new SqlCommand("SELECT notifications.*, accounts.name, accounts.rooms FROM rohbot.accounts INNER JOIN rohbot.notifications ON (rohbot.accounts.id = rohbot.notifications.userid)"); Notifications = cmd.Execute().Select(row => new Notification(row)).ToList(); }