Exemple #1
0
        //public User_VideoGame GetByUserId(int id)
        //{
        //    User_VideoGame user_VideoGame = new User_VideoGame();

        //    using (_connection)
        //    {
        //        _connection.Open();

        //        using (SqlCommand cmd = _connection.CreateCommand())
        //        {
        //            //cmd.CommandText = "SELECT u.UserId, u.UserName, vg.Name, pl.PlateformName" +
        //            //    " FROM [USER] u JOIN USER_VIDEOGAME uv ON u.UserId = uv.UserId" +
        //            //    " JOIN PLATEFORM_VIDEOGAME plvg ON uv.Plateform_VideoGameId = plvg.Id JOIN" +
        //            //    " PLATEFORM pl ON PlVg.PlateformId = pl.PlateformId" +
        //            //    " JOIN VIDEOGAME vg ON plvg.VideoGameId = vg.VideoGameId WHERE u.UserId = @id";

        //            cmd.CommandText = "SELECT UserId, User_VideoGame_id, Plateform_VideoGameId FROM USER_VIDEOGAME WHERE User_VideoGame_id=@id";

        //            cmd.Parameters.AddWithValue("id", id);

        //            using (SqlDataReader reader = cmd.ExecuteReader())
        //            {
        //                while (reader.Read())
        //                {
        //                    user_VideoGame.User_VideoGame_id = (int)reader["User_VideoGame_id"];
        //                    user_VideoGame.UserId = (int)reader["UserId"];
        //                    user_VideoGame.Plateform_VideoGame_Id = (int)reader["Plateform_VideoGameId"];
        //                    //user_VideoGame.UserName = (string)reader["UserName"];
        //                    //user_VideoGame.VideoGameName = (string)reader["Name"];
        //                    //user_VideoGame.PlateformName = (string)reader["PlateformName"];
        //                    //user_VideoGame.videoGamesList.Add(reader.GetString("Name"));
        //                    //user_VideoGame.PlateformList.Add(reader.GetString("PlateformName"));
        //                }

        //                return user_VideoGame;
        //            }
        //        }
        //    }
        //}

        public void Insert(User_VideoGame user_VideoGame)
        {
            using (_connection)
            {
                _connection.Open();

                using (SqlCommand cmd = _connection.CreateCommand())
                {
                    cmd.CommandText = " INSERT INTO USER_VIDEOGAME (UserId, VideoGameId)" +
                                      " OUTPUT inserted.User_VideoGame_id VALUES (@UId, @VgId)";

                    cmd.Parameters.AddWithValue("UId", user_VideoGame.UserId);
                    cmd.Parameters.AddWithValue("VgId", user_VideoGame.VideoGameId);


                    int id = (int)cmd.ExecuteScalar();
                }
            }
        }
Exemple #2
0
        public void Update(User_VideoGame user_VideoGame)
        {
            using (_connection)
            {
                _connection.Open();

                using (SqlCommand cmd = _connection.CreateCommand())
                {
                    cmd.CommandText = "UPDATE USER_VIDEOGAME SET UserId = @UId," +
                                      " Plateform_VideoGameId = @VgId" +
                                      " WHERE User_VideoGame_id = @id";

                    cmd.Parameters.AddWithValue("UId", user_VideoGame.UserId);
                    cmd.Parameters.AddWithValue("VgId", user_VideoGame.VideoGameId);
                    cmd.Parameters.AddWithValue("id", user_VideoGame.User_VideoGame_id);

                    cmd.ExecuteNonQuery();
                }
            }
        }
 public IActionResult Put([FromBody] User_VideoGame user_VideoGame)
 {
     _service.Update(user_VideoGame);
     return(Ok());
 }
 public IActionResult Post([FromBody] User_VideoGame user_VideoGame)
 {
     _service.Insert(user_VideoGame);
     return(Ok());
 }
Exemple #5
0
 public void Update(User_VideoGame user_VideoGame)
 {
     _UvRepo.Update(user_VideoGame.toDal());
 }
Exemple #6
0
 public void Insert(User_VideoGame user_VideoGame)
 {
     _UvRepo.Insert(user_VideoGame.toDal());
 }