Exemplo n.º 1
0
        public static string ConstructSearchParameters(SearchBlockModel model)
        {
            Repository <Category> categoryRepository = new Repository <Category>();

            string name     = "Name:" + model.Name;
            string category = (model.CategoryId == "-1") ? "" : "Category:" + categoryRepository.GetById(int.Parse(model.CategoryId)).Name;

            string searchParameters = string.Join(";", new string[] { name, category });

            return(searchParameters);
        }
Exemplo n.º 2
0
        public ActionResult Blocks()
        {
            IEnumerable <Category> categories = categoryRepository.Query();

            SearchBlockModel model = new SearchBlockModel();

            model.AllCategories = categories;
            model.Action        = "Blocks";
            model.Controller    = "Search";

            var blocks = blockService.GetAll(20);

            ViewBag.listItems = blocks.ToList();

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Blocks(SearchBlockModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("Search/Blocks"));
            }

            IEnumerable <Category> categories = categoryRepository.Query();

            model.AllCategories = categories;

            string searchParameters = SearchHelper.ConstructSearchParameters(model);

            Debug.WriteLine(searchParameters);

            var blocks = blockService.Search(searchParameters, 20);

            ViewBag.listItems = blocks.ToList();

            return(View(model));
        }