private void SetCheckBoxValueToTempData(MovieDisplayAdvancedVM viewModel) { TempData["Search"] = viewModel.SearchBox; TempData["DisplayAction"] = viewModel.DisplayActionBool.ToString(); //Spara action boolen TempData["DisplayComedy"] = viewModel.DisplayComedyBool.ToString(); //Spara action boolen TempData["DisplayRomance"] = viewModel.DisplayRomanceBool.ToString(); //Spara action boolen }
public IActionResult Index(MovieDisplayAdvancedVM viewModel) { TempData["Search"] = viewModel.SearchBox; TempData["DisplayAction"] = viewModel.DisplayActionBool.ToString(); //Spara action boolen TempData["DisplayComedy"] = viewModel.DisplayComedyBool.ToString(); //Spara action boolen TempData["DisplayRomance"] = viewModel.DisplayRomanceBool.ToString(); //Spara action boolen return(RedirectToAction(nameof(MoviesController.Index))); }
public IActionResult Display(MovieDisplayAdvancedVM viewModel) { TempData["ChosenGenre"] = viewModel.Filter.SelectedGenre; TempData["Search"] = viewModel.SearchBox; string Searchinfo = "Result for \"" + viewModel.SearchBox + "\" in genre \"" + viewModel.Filter.SelectedGenre + "\""; TempData["SearchInfo"] = Searchinfo; return(RedirectToAction(nameof(MoviesController.Display))); }
public IActionResult Index() { MovieDisplayAdvancedVM viewModel = new MovieDisplayAdvancedVM(); viewModel.SearchBox = (string)TempData["Search"]; string genreCheckbox = ""; if ((string)TempData["DisplayAction"] == "True") { genreCheckbox += "Action"; } if ((string)TempData["DisplayComedy"] == "True") { genreCheckbox += "Comedy"; } if ((string)TempData["DisplayRomance"] == "True") { genreCheckbox += "Romance"; } if (viewModel.SearchBox == null) { viewModel.ListViewModels = context.ListMovies("", ""); } else { viewModel.ListViewModels = context.ListMovies(viewModel.SearchBox, genreCheckbox); } return(View(viewModel)); #region Test (bra egentligen) //else if (viewModel.DisplayAction) // viewModel.ListViewModels = context.ListMovies("Action"); //else if (viewModel.DisplayRomance) // viewModel.ListViewModels = context.ListMovies("Romance"); //context.ListMovies("Action").CopyTo(viewModel.ListViewModels, 0); //context.ListMovies("Romance").CopyTo(viewModel.ListViewModels, 1); //if (!viewModel.DisplayAction) // Array.Copy(context.ListMovies("Romance"), viewModel.ListViewModels, context.ListMovies("Romance").Length); // viewModel.ListViewModels = context.ListMovies("Action"); // if (!viewModel.DisplayAction) // Array.Copy(context.ListMovies("Action"), viewModel.ListViewModels, context.ListMovies("Action").Length); #endregion }
public IActionResult Display() { MovieDisplayAdvancedVM viewModel = new MovieDisplayAdvancedVM(); viewModel.Filter = new FilterGenre { Genres = new List <GenreVM> { new GenreVM { Id = 1, TypeOfGenre = "All genres" }, new GenreVM { Id = 2, TypeOfGenre = "Action" }, new GenreVM { Id = 3, TypeOfGenre = "Drama" }, new GenreVM { Id = 4, TypeOfGenre = "Comedy" }, } }; viewModel.Searchinfo = (string)TempData["SearchInfo"]; viewModel.SearchBox = (string)TempData["Search"]; string chosenGenre; if ((string)TempData["ChosenGenre"] == "All genres" || (string)TempData["ChosenGenre"] == null) { chosenGenre = ""; } else { chosenGenre = (string)TempData["ChosenGenre"]; } //If the user left the the searchbox empty, return all movies //for the selected genre. if (viewModel.SearchBox == null) { viewModel.ListViewModels = context.ListMovies("", chosenGenre); } else { viewModel.ListViewModels = context.ListMovies(viewModel.SearchBox, chosenGenre); } return(View(viewModel)); }
public IActionResult Display() { MovieDisplayAdvancedVM viewModel = new MovieDisplayAdvancedVM(); string genreCheckbox = SetSavedTempDataToGenreString(viewModel); if (viewModel.SearchBox != null || genreCheckbox != "") { viewModel.ListViewModels = context.SearchMovies(viewModel.SearchBox, genreCheckbox); } else { viewModel.ListViewModels = context.ListMovies(""); } ClearTempData(); return(View(viewModel)); }
private string SetSavedTempDataToGenreString(MovieDisplayAdvancedVM viewModel) { viewModel.SearchBox = (string)TempData["Search"]; string genreCheckbox = ""; if ((string)TempData["DisplayAction"] == "True") { genreCheckbox += "Action"; } if ((string)TempData["DisplayComedy"] == "True") { genreCheckbox += "Comedy"; } if ((string)TempData["DisplayRomance"] == "True") { genreCheckbox += "Romance"; } return(genreCheckbox); }
public IActionResult Index() { MovieDisplayAdvancedVM viewModel = new MovieDisplayAdvancedVM(); viewModel.SearchBox = (string)TempData["Search"]; string genreCheckbox = ""; if ((string)TempData["DisplayAction"] == "True") { genreCheckbox += "Action"; } if ((string)TempData["DisplayComedy"] == "True") { genreCheckbox += "Comedy"; } if ((string)TempData["DisplayRomance"] == "True") { genreCheckbox += "Romance"; } if (viewModel.SearchBox != null || genreCheckbox != "") { viewModel.ListViewModels = context.SearchMovies(viewModel.SearchBox, genreCheckbox); } else { viewModel.ListViewModels = context.ListMovies(); } TempData["DisplayAction"] = ""; TempData["DisplayComedy"] = ""; TempData["DisplayRomance"] = ""; return(View(viewModel)); }
public IActionResult Display(MovieDisplayAdvancedVM viewModel) { SetCheckBoxValueToTempData(viewModel); return(RedirectToAction("Display")); }