public IEnumerable <Movie> GetMovie() { DataTable data = DBX.ExecQuery($"select * from Movie"); if (data.Rows.Count > 0) { List <Movie> movies = new List <Movie>(); for (int i = 0; i < data.Rows.Count - 1; i++) { Movie movie = new Movie(); movie.movie_id = int.Parse(data.Rows[i]["Id"].ToString()); movie.title = data.Rows[i]["Title"].ToString(); movie.price = decimal.Parse(data.Rows[i]["Price"].ToString()); movie.genre = data.Rows[i]["Genre"].ToString(); movie.releaseDate = DateTime.Parse(data.Rows[i]["ReleaseDate"].ToString()); movies.Add(movie); } return(movies); } else { return(null); } }
public Movie GetMovie(int id) { DataTable data = DBX.ExecQuery($"select * from Movie where Id = {id}"); if (data.Rows.Count > 0) { Movie movie = new Movie(); movie.movie_id = int.Parse(data.Rows[0]["Id"].ToString()); movie.title = data.Rows[0]["Title"].ToString(); movie.price = decimal.Parse(data.Rows[0]["Price"].ToString()); movie.genre = data.Rows[0]["Genre"].ToString(); movie.releaseDate = DateTime.Parse(data.Rows[0]["ReleaseDate"].ToString()); return(movie); } else { return(null); } }