예제 #1
0
        [HttpGet("GetGameByName/{gameName}/")] //Route: WebAPI/TermProject/GetGameByName/
        public List <VideoGames> GetGameByName(string gameName)
        {
            DataSet          myDS    = new DataSet();
            StoredProcedures stoPros = new StoredProcedures();

            //string query = "SELECT * FROM TP_Actor";

            myDS = stoPros.getGameByName(gameName);

            DBConnect objDB = new DBConnect();
            //DataSet ds = objDB.GetDataSet(query);

            VideoGames        videogames = new VideoGames();
            List <VideoGames> dpts       = new List <VideoGames>();

            foreach (DataRow dr in myDS.Tables[0].Rows)
            {
                videogames                 = new VideoGames();
                videogames.GameID          = int.Parse(dr["Video_Game_ID"].ToString());
                videogames.GameName        = dr["Video_Game_Name"].ToString();
                videogames.GameYear        = int.Parse(dr["Video_Game_Year"].ToString());
                videogames.GameDescription = dr["Video_Game_Description"].ToString();
                videogames.GameCreator     = dr["Video_Game_Creator"].ToString();
                videogames.GameAgeRating   = dr["Video_Game_Age_Rating"].ToString();
                videogames.GameGenre       = dr["Video_Game_Genre"].ToString();
                videogames.GameImage       = dr["Video_Game_Image"].ToString();
                dpts.Add(videogames);
            }
            return(dpts);
        } //end of getgamesbyname
예제 #2
0
        public Boolean AddGame([FromBody] VideoGames game)
        {
            if (game != null)
            {
                DBConnect  objDB      = new DBConnect();
                SqlCommand objCommand = new SqlCommand();

                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "TP_AddGame";
                objCommand.Parameters.AddWithValue("@Member_ID", game.MemberID);

                objCommand.Parameters.AddWithValue("@Game_Image", game.GameImage);
                objCommand.Parameters.AddWithValue("@Game_Name", game.GameName);
                objCommand.Parameters.AddWithValue("@Game_Year", game.GameYear);
                objCommand.Parameters.AddWithValue("@Game_Genre", game.GameGenre);
                objCommand.Parameters.AddWithValue("@Game_Description", game.GameDescription);
                objCommand.Parameters.AddWithValue("@Game_Creator", game.GameCreator);
                objCommand.Parameters.AddWithValue("@Game_Age_Rating", game.GameAgeRating);

                int retVal = objDB.DoUpdateUsingCmdObj(objCommand);

                if (retVal > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        [HttpGet("GetGames")] //Route: WebAPI/TermProject/GetGames/
        public List <VideoGames> GetGames()
        {
            DataSet          myDS    = new DataSet();
            StoredProcedures stoPros = new StoredProcedures();

            myDS = stoPros.getAllGames();

            DBConnect objDB = new DBConnect();

            VideoGames        videogames = new VideoGames();
            List <VideoGames> dpts       = new List <VideoGames>();

            foreach (DataRow dr in myDS.Tables[0].Rows)
            {
                videogames                 = new VideoGames();
                videogames.GameID          = int.Parse(dr["Video_Game_ID"].ToString());
                videogames.GameName        = dr["Video_Game_Name"].ToString();
                videogames.GameYear        = int.Parse(dr["Video_Game_Year"].ToString());
                videogames.GameDescription = dr["Video_Game_Description"].ToString();
                videogames.GameCreator     = dr["Video_Game_Creator"].ToString();
                videogames.GameAgeRating   = dr["Video_Game_Age_Rating"].ToString();
                videogames.GameGenre       = dr["Video_Game_Genre"].ToString();
                videogames.GameImage       = dr["Video_Game_Image"].ToString();
                dpts.Add(videogames);
            }
            return(dpts);
        }