Esempio n. 1
0
        //
        // GET: /Planet/
        public ActionResult Index()
        {
            var model = new PlanetPageViewModel
            {
                IsAjax = Request.IsAjaxRequest(),
                ActionName = "Planet/Index",
                SearchForm = new PlanetSearch()
            };

            if (Request.IsAjaxRequest())
            {
                return PartialView("_Index", model);
            }

            return View(model);
        }
Esempio n. 2
0
        public ActionResult List()
        {
            var planets = planetRepository.GetAll();

            var model = new PlanetPageViewModel
            {
                IsAjax = Request.IsAjaxRequest(),
                ActionName = "Planet/List",
                Planets = planets,
                SearchForm = new PlanetSearch()
            };

            if (Request.IsAjaxRequest())
            {
                return PartialView("_List", model);
            }

            return View(model);
        }
Esempio n. 3
0
        public ActionResult Search(PlanetSearch search)
        {
            Planet planet = null;

            if (search.Id.HasValue)
            {
                planet = planetRepository.GetAll().Where(p => p.Id == search.Id.GetValueOrDefault(0)).FirstOrDefault();
            }
            else
            {
                var name = (search.Name ?? "").Trim().ToUpper();
                planet = planetRepository.GetAll().Where(p => p.Name.ToUpper() == name).FirstOrDefault();
            }
            var searchResults = new List<Planet>() { };

            if (planet != null)
            {
                searchResults.Add(planet);
            }

            var model = new PlanetPageViewModel
            {
                IsAjax = Request.IsAjaxRequest(),
                ActionName = "Planet/Search",
                Planets = searchResults,
                SearchForm = search
            };

            var result = new AjaxifiedResult(model: model, fullView: "Search", partialView: "_List");
            // return AjaxifiedResult(model: model, fullView: "Search", partialView: "_List");

            if (Request.IsAjaxRequest())
            {
                return PartialView("_List", model);
            }
            return View(model);
        }