コード例 #1
0
ファイル: Movie_Repo.cs プロジェクト: reyhanfikri/tubesprovis
        public Movie_Class getById(int Id)
        {
            try
            {
                string query = "SELECT * FROM tb_movie  WHERE id_movie = " + Id + ";";

                OpenConnection();
                Movie_Class hasil = myConn.Query <Movie_Class>(query, new { id = Id }).FirstOrDefault();
                closeConnection();

                return(hasil);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: Movie_Repo.cs プロジェクト: reyhanfikri/tubesprovis
        public void insertNewMovie(Movie_Class movie)
        {
            try
            {
                int     id_genre       = movie.Id_genre;
                string  judul          = movie.Judul;
                int     tahun_produksi = movie.Tahun_produksi;
                int     durasi         = movie.Durasi;
                decimal rating_imdb    = movie.Rating_imdb;
                string  rated          = movie.Rated;
                string  bahasa         = movie.Bahasa;
                string  subtitle       = movie.Subtitle;

                string query = "INSERT INTO tb_movie VALUES (null, '" + id_genre + "', '" + judul + "', '" + tahun_produksi + "', '" + durasi + "', '" + rating_imdb + "', '" + rated + "', '" + bahasa + "', '" + subtitle + "')";

                OpenConnection();
                var hasil = myConn.Execute(query);
                closeConnection();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }