// Populates a List with Film Data public List<clsUserreviewDetails> GenerateFilmList(string search) { // Datatable variable to hold select result DataTable resultsDataTable = new DataTable(); // List to hold conversion from Datatable to list List<clsUserreviewDetails> listFilmDetails = new List<clsUserreviewDetails>(); // Get Dsatatable clsDataBaseFunctions getResults = new clsDataBaseFunctions(); resultsDataTable = getResults.SelectAllFilms(search); Int32 index = 0; Int32 recordNo = resultsDataTable.Rows.Count; ; while (index < recordNo) { clsUserreviewDetails newFilm = new clsUserreviewDetails ( // Convert Datatable values by row to constructor values Convert.ToInt32(resultsDataTable.Rows[index]["film_Id"]), Convert.ToString(resultsDataTable.Rows[index]["filmName"]), Convert.ToString(resultsDataTable.Rows[index]["filmDescription"]) ); listFilmDetails.Add(newFilm); index++; } return listFilmDetails; }
// Populates a List with User Comments Data public List<clsUserFilmReview> GenerateUserCommentList(string search) { // Datatable variable to hold select result DataTable resultsDataTable = new DataTable(); // List to hold conversion from Datatable to list List<clsUserFilmReview> listUserComments = new List<clsUserFilmReview>(); // Get Dsatatable clsDataBaseFunctions getResults = new clsDataBaseFunctions(); resultsDataTable = getResults.SelectUserCommentsByFilm(search); Int32 index = 0; Int32 recordNo = resultsDataTable.Rows.Count; ; while (index < recordNo) { clsUserFilmReview newUserReview = new clsUserFilmReview ( // Convert Datatable values by row to constructor values Convert.ToInt32(resultsDataTable.Rows[index]["FK_user_Id"]), Convert.ToString(resultsDataTable.Rows[index]["userName"]), Convert.ToString(resultsDataTable.Rows[index]["commentDetails"]) ); listUserComments.Add(newUserReview); index++; } return listUserComments; }