public void Save() { var cmd = new SqlCommand("UPDATE rohbot.notifications SET regex=:regex WHERE id=:id"); cmd["id"] = Id; cmd["regex"] = Regex.ToString(); cmd.ExecuteNonQuery(); }
public void Remove() { var cmd = new SqlCommand("DELETE FROM rohbot.notifications WHERE devicetoken=:devicetoken AND userid=:userid"); cmd["devicetoken"] = DeviceToken; cmd["userid"] = UserId; cmd.ExecuteNonQuery(); }
public void Insert() { var cmd = new SqlCommand("INSERT INTO rohbot.notifications (userid, regex, devicetoken) VALUES(:userid, :regex, :devicetoken) RETURNING id;"); cmd["userid"] = UserId; cmd["regex"] = Regex.ToString(); cmd["devicetoken"] = DeviceToken; Id = (long)cmd.ExecuteScalar(); }
public override void Insert() { if (Id != 0) throw new InvalidOperationException("Cannot insert existing row"); var cmd = new SqlCommand("INSERT INTO rohbot.chathistory (type,date,chat,content,usertype,sender,senderid,senderstyle,ingame)" + "VALUES (:type,:date,:chat,:content,:usertype,:sender,:senderid,:senderstyle,:ingame) RETURNING id;"); cmd["type"] = Type; cmd["date"] = Date; cmd["chat"] = Chat; cmd["content"] = Content; cmd["usertype"] = UserType; cmd["sender"] = Sender; cmd["senderid"] = SenderId; cmd["senderstyle"] = SenderStyle; cmd["ingame"] = InGame; Id = (long)cmd.ExecuteScalar(); }
public override void Insert() { if (Id != 0) throw new InvalidOperationException("Cannot insert existing row"); var cmd = new SqlCommand("INSERT INTO rohbot.chathistory (type,date,chat,content,state,\"for\",forid,fortype,forstyle,by,byid,bytype,bystyle)" + "VALUES (:type,:date,:chat,:content,:state,:for,:forid,:fortype,:forstyle,:by,:byid,:bytype,:bystyle) RETURNING id;"); cmd["type"] = Type; cmd["date"] = Date; cmd["chat"] = Chat; cmd["content"] = Content; cmd["state"] = State; cmd["for"] = For; cmd["forid"] = ForId; cmd["fortype"] = ForType; cmd["forstyle"] = ForStyle; cmd["by"] = By; cmd["byid"] = ById; cmd["bytype"] = ByType; cmd["bystyle"] = ByStyle; Id = (long)cmd.ExecuteScalar(); }
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(); }