コード例 #1
0
        public IActionResult Search(FilmSearch search)
        {
            // TODO: Show model binding into the FilmSearch object

            // If values were passed in, do a search. If not show the view with no model

            // TODO: Use ViewData to pass a "Message" into the view.
            // TODO: Add code to _Layout to look for that message.
            if (search == null || (search.SearchFor == null && search.Series == null))
            {
                ViewData["Message"] = "Please enter search criteria and press Search";
                return(View());
            }
            // Get List of films that match the search
            IStarWarsDAO dao = new MockStarWarsDAO();

            // TODO: Change this DAO to a SQL DAO to get the "production" data

            IList <Film> films = dao.GetFilms(search.SearchFor, search.Series);

            // TODO: If no films were returned, show a "Message" to the use that there were no search results.
            if (films.Count == 0)
            {
                ViewData["Message"] = "Your search produced no results. Please try again";
            }
            return(View(films));
        }
コード例 #2
0
        public IActionResult Index()
        {
            IStarWarsDAO dao   = new MockStarWarsDAO();
            var          films = dao.GetFilms();

            return(View("Index", films));
        }
コード例 #3
0
        public IActionResult Index()
        {
            // Get a list of all films (our Model)
            IStarWarsDAO dao   = new MockStarWarsDAO();
            IList <Film> films = dao.GetFilms();

            return(View(films));
        }
コード例 #4
0
        public IActionResult Index()
        {
            // Instantiated the dao object
            IStarWarsDAO dao = new MockStarWarsDAO();
            // Asked the DAO to get me all the films and assign to the variable movies
            IList <Film> movies = dao.GetFilms();

            // Pass the variable movies into the razor engine to bind to the view
            return(View(movies));
        }
コード例 #5
0
        public IActionResult Index()
        {
            var db = new MockStarWarsDAO();
            var vm = new FilmIndexViewModel();

            vm.Films = db.GetFilms();
            //vm.Age = 18;
            //vm.Height = 74;

            return(View(vm));
        }
コード例 #6
0
        public IActionResult Index()
        {
            // Get a list of all film
            MockStarWarsDAO dao   = new MockStarWarsDAO();
            IList <Film>    films = dao.GetFilms();

            // Pass the list of films into the View


            ViewResult viewResult = View(films);

            return(View(films));
        }