Пример #1
0
        public static async Task <UserPostingHistory> GetUserPostingHistory(string userName)
        {
            using (var con = DirtBagConnection.GetConn()) {
                var query = "" +
                            "Select up.ChannelID, up.ThingID  " +
                            "FROM dirtbag.UserPosts up " +
                            //"left JOIN dirtbag.PostRemovals rem on up.PostID = rem.PostID " +
                            "where username like @UserName " +
                            "and up.ChannelID is not null " +
                            //"group by channelid";
                            "";

                UserPostingHistory results = new UserPostingHistory();
                results.UserName       = userName;
                results.PostingHistory = new Dictionary <string, List <string> >();

                var vals = await con.QueryAsync(query, param : new { userName });

                foreach (dynamic kv in vals)
                {
                    if (!results.PostingHistory.ContainsKey(kv.ChannelID))
                    {
                        results.PostingHistory.Add(kv.ChannelID, new List <string>());
                    }

                    results.PostingHistory[kv.ChannelID].Add(kv.ThingID);
                }
                return(results);
            }
        }
Пример #2
0
        public static async Task<UserPostingHistory> GetUserPostingHistory( string userName ) {
            using ( var con = DirtBagConnection.GetConn() ) {
                var query = "" +
                    "Select up.ChannelID, up.ThingID  " +
                    "FROM dirtbag.UserPosts up " +
                    //"left JOIN dirtbag.PostRemovals rem on up.PostID = rem.PostID " +
                    "where username like @UserName " +
                    "and up.ChannelID is not null " +
                    //"group by channelid";
                    "";

                UserPostingHistory results = new UserPostingHistory();
                results.UserName = userName;
                results.PostingHistory = new Dictionary<string, List<string>>();

                var vals = await con.QueryAsync( query, param: new { userName } );
                foreach(dynamic kv in vals ) {
                    if ( !results.PostingHistory.ContainsKey( kv.ChannelID ) )
                        results.PostingHistory.Add( kv.ChannelID, new List<string>() );

                    results.PostingHistory[kv.ChannelID].Add( kv.ThingID );
                }
                return results;
            }
        }