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 DeleteGame(string username, int gameId) { using (SqlConnection conn = DbConnectionFactory.CreateSqlConnection()) using (SqlCommand command = new SqlCommand("DeleteGame", conn)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@GameID", gameId); command.Parameters.AddWithValue("@Username", username); using (SqlDataReader reader = command.ExecuteReader()) { return(JsonUtils.CreateJsonFromSqlReader(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)); } } }