public static JToken GetTopics()
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("SubForum_Select", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonArrayFromSqlReader(reader));
                    }
                }
        }
Exemple #2
0
        public static JToken GetThreads(int topicId)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("Thread_Select", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@SubForumID", topicId);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonArrayFromSqlReader(reader));
                    }
                }
        }
        public static JToken GetGenre(int genreId)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("Genres_Select", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@GenreId", genreId);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonFromSqlReader(reader));
                    }
                }
        }
        public static JToken GameInfo(string username)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("GameInfo", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@Username", username);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonArrayFromSqlReader(reader));
                    }
                }
        }
Exemple #5
0
        public static JToken GetUsers(int userId)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("Users_Select", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    //if (!string.IsNullOrEmpty(clientIdentifier))
                    command.Parameters.AddWithValue("@UserID", userId);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonArrayFromSqlReader(reader));
                    }
                }
        }
        public static JToken InsertGenre(GenreAPIModel genre)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("AddGenre", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@GenreId", genre.Id);
                    command.Parameters.AddWithValue("@GenreName", genre.Name);
                    //command.Parameters.AddWithValue("@GameId", platform.Cover);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonFromSqlReader(reader));
                    }
                }
        }
        public static JToken InsertPlatform(PlatformAPIModel platform)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("AddPlatform", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@PlatformId", platform.Id);
                    command.Parameters.AddWithValue("@PlatformName", platform.Name);
                    command.Parameters.AddWithValue("@Logo", platform.Logo == null ? "https://www.picclickimg.com/00/s/MTYwMFgxNjAw/z/8xgAAOSwr81USRqc/$/Nintendo-WII-DVD-Video-Game-Case-White-Blank-_57.jpg" : platform.Logo.url);
                    //command.Parameters.AddWithValue("@GameId", platform.Cover);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonFromSqlReader(reader));
                    }
                }
        }
        public static JToken InsertGame(string username, GameModel game)
        {
            using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection())
                using (SqlCommand command = new SqlCommand("AddGame", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@GameID", game.GameId);
                    command.Parameters.AddWithValue("@Username", username);
                    command.Parameters.AddWithValue("@GameName", game.Name);
                    command.Parameters.AddWithValue("@Summary", game.Summary);
                    command.Parameters.AddWithValue("@Genres", game.GenresStr);
                    command.Parameters.AddWithValue("@Platforms", game.PlatformsStr);
                    command.Parameters.AddWithValue("@Cover", game.Cover);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        return(JsonUtils.CreateJsonFromSqlReader(reader));
                    }
                }
        }