Exemplo n.º 1
0
        /// <summary>
        /// Fetches the bans.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="chatRoomId">The chat room id.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="userIp">The user ip.</param>
        /// <param name="expiresAfter">The expires after.</param>
        /// <returns></returns>
        public static List<ChatBan> FetchBans(int? id, int? chatRoomId, int? userId, string userIp,
            DateTime expiresAfter)
        {
            List<ChatBan> bans = new List<ChatBan>();

            using (SqlConnection conn = DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchChatBans", id, chatRoomId,
                    userId, userIp, expiresAfter);

                while (reader.Read())
                {
                    ChatBan ban = new ChatBan();

                    ban.id = (int)reader["Id"];
                    ban.chatRoomId = DB.ParseDBNull<int?>(reader["ChatRoomId"]);
                    ban.userId = DB.ParseDBNull<int?>(reader["UserId"]);
                    ban.userIp = DB.ParseDBNull<string>(reader["UserIp"]);
                    ban.banDate = (DateTime) reader["BanDate"];
                    ban.banExpires = DB.ParseDBNull<DateTime?>(reader["BanExpires"]);

                    bans.Add(ban);
                }
            }

            return bans;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a user ban for the specified chat room id.
 /// </summary>
 /// <param name="chatRoomId">The chat room id.</param>
 /// <param name="userId">The user id.</param>
 /// <returns></returns>
 public static ChatBan Create(int? chatRoomId, int userId)
 {
     ChatBan ban = new ChatBan();
     ban.chatRoomId = chatRoomId;
     ban.userId = userId;
     ban.banDate = DateTime.Now;
     return ban;
 }