private void UpdateMovieTable() { for (int i = 1; i < MovieTable.Rows.Count; i++) { MovieTable.Rows.RemoveAt(i); } List <Movie> movieList = new List <Movie>(); movieList = MovieManager.OutputMovies(); foreach (Movie movie in movieList) { //Adds all the genres to one string. string allGenre = ""; foreach (string genre in movie.genre) { allGenre += genre + " "; } //Makes a new table row and - cells and sets the class for each of them. TableRow row = new TableRow() { CssClass = "row" }; TableCell cell1 = new TableCell() { Text = $"{movie.id}", CssClass = "col-3" }; TableCell cell2 = new TableCell() { Text = $"{movie.title}", CssClass = "col-3" }; TableCell cell3 = new TableCell() { Text = $"{movie.releaseYear}", CssClass = "col-3" }; TableCell cell4 = new TableCell() { Text = $"{allGenre}", CssClass = "col-3" }; //Adds the cells to the row in the table. row.Cells.Add(cell1); row.Cells.Add(cell2); row.Cells.Add(cell3); row.Cells.Add(cell4); //Adds the row to the table MovieTable.Rows.Add(row); } }
protected void SubmitNewMovie(object sender, EventArgs e) { List <string> strList = new List <string>(); if (Request.Form["Action"] != null) { strList.Add("Action"); } if (Request.Form["Drama"] != null) { strList.Add("Drama"); } if (Request.Form["Horror"] != null) { strList.Add("Horror"); } string movieTitle = Request.Form["NewMovieTitle"]; int movieReleaseYear = Convert.ToInt32(Request.Form["NewMovieReleaseYear"]); Movie newMovie = new Movie(strList, movieTitle, movieReleaseYear); MovieManager.AddMovie(newMovie); }