public bool TryParticipate(DbEventParticipation p) { try { return(Context.Connection.Execute("INSERT INTO fso_event_participation (event_id, user_id) VALUES (@event_id, @user_id)", p) > 0); } catch { //already exists, or foreign key fails return(false); } }
public bool Participated(DbEventParticipation p) { return(Context.Connection.Query <int>("SELECT count(*) FROM fso_event_participation WHERE event_id = @event_id AND user_id = @user_id", p).First() > 0); }