public ActionResult Search(SearchFurnitureFormViewModel requestedViewModel)
        {
            var results = FurnitureService.Search(
                requestedViewModel.PartNumber,
                requestedViewModel.SelectedTypes,
                requestedViewModel.SelectedDesigner,
                requestedViewModel.Year.Min,
                requestedViewModel.Year.Max,
                requestedViewModel.Price.Min,
                requestedViewModel.Price.Max
            );

            if (results.Count(x => x.PartNumber == requestedViewModel.PartNumber) == 1)
            {
                return RedirectToAction("Show", new { id = requestedViewModel.PartNumber });
            }
            else if (results.Count() == 0)
            {
                requestedViewModel.Types = FurnitureService.GetTypes();
                requestedViewModel.Designers = FurnitureService.GetDesigners().Select(x => new KeyValuePair<string, string>(x.FullName, x.DesignerId.ToString()));
                ViewBag.NoResults = true;
                return View("Search", new SearchFurnitureViewModel("Møbler", "furnitures")
                {
                    SearchForm = requestedViewModel
                });
            }

            return View("SearchResult", new SearchResultFurnitureViewModel("Møbler", "furnitures")
            {
                Results = results
            });
        }
        public ActionResult Search(SearchFurnitureFormViewModel requestedViewModel)
        {
            var results = FurnitureService.Search(
                requestedViewModel.PartNumber,
                requestedViewModel.SelectedTypes,
                requestedViewModel.SelectedDesigner,
                requestedViewModel.Year.Min,
                requestedViewModel.Year.Max,
                requestedViewModel.Price.Min,
                requestedViewModel.Price.Max
                );

            if (results.Count(x => x.PartNumber == requestedViewModel.PartNumber) == 1)
            {
                return(RedirectToAction("Show", new { id = requestedViewModel.PartNumber }));
            }
            else if (results.Count() == 0)
            {
                requestedViewModel.Types     = FurnitureService.GetTypes();
                requestedViewModel.Designers = FurnitureService.GetDesigners().Select(x => new KeyValuePair <string, string>(x.FullName, x.DesignerId.ToString()));
                ViewBag.NoResults            = true;
                return(View("Search", new SearchFurnitureViewModel("Møbler", "furnitures")
                {
                    SearchForm = requestedViewModel
                }));
            }

            return(View("SearchResult", new SearchResultFurnitureViewModel("Møbler", "furnitures")
            {
                Results = results
            }));
        }
        public ActionResult Search(SearchFurnitureFormViewModel requestedViewModel)
        {
            //TODO: PRG pattern for search
            return(View());

            return(RedirectToAction("SearchResult"));
        }
 public ActionResult Search(SearchFurnitureFormViewModel requestedViewModel)
 {
     //TODO: PRG pattern for search
     return View();
     return RedirectToAction("SearchResult");
 }