Beispiel #1
0
        public ActionResult Search(SubmitSearchModel searchModel)
        {
            var result = this.data.Laptops.All();

            if (!string.IsNullOrEmpty(searchModel.ModelQuery))
            {
                result = result.Where(
                    lap => lap.Model.ToLower().Contains(searchModel.ModelQuery.ToLower()));
            }

            if (searchModel.ManufacturerQuery != "All")
            {
                result = result.Where(
                    lap => lap.Manufacturer.Name.ToLower().Contains(searchModel.ManufacturerQuery.ToLower()));
            }

            if (searchModel.PriceQuery != 0)
            {
                result = result.Where(
                    lap => lap.Price <= searchModel.PriceQuery);
            }

            var endResult = result.Select(LaptopViewModel.FromLaptop).ToList();

            return(View(endResult));
        }
Beispiel #2
0
        public ActionResult Search(SubmitSearchModel submitModel)
        {
            var result = this.Data.Laptops.All();

            if (!string.IsNullOrEmpty(submitModel.ModelSearch))
            {
                result = result.Where(x => x.Model.ToLower().Contains(submitModel.ModelSearch.ToLower()));
            }

            if (submitModel.ManufSearch != "All")
            {
                result = result.Where(x => x.Manufacturer.Name == submitModel.ManufSearch);
            }

            if (submitModel.PriceSearch != 0)
            {
                result = result.Where(x => x.Price < submitModel.PriceSearch);
            }

            var endResult = result.Select(x => new LaptopViewModel
            {
                Id           = x.Id,
                Model        = x.Model,
                Manufacturer = x.Manufacturer.Name,
                ImageUrl     = x.ImageUrl,
                Price        = x.Price
            });

            return(View(endResult));
        }
Beispiel #3
0
        public ActionResult Search(SubmitSearchModel submitSearchModel)
        {
            var searchCategory = submitSearchModel.Category;
            var tickets        = this.Data.GetRepository <Ticket>().All();

            if (searchCategory != "All")
            {
                tickets = tickets.Where(t => t.Category.Name == searchCategory);
            }

            var result = tickets.Select(TicketViewModel.FromTicket);

            return(View(result));
        }
        public ActionResult Search(SubmitSearchModel submitModel)
        {
            var result = this.Data.Smartphones.All();

            if (!string.IsNullOrEmpty(submitModel.ModelSearch))
            {
                result = result.Where(x => x.Model.ToLower().Contains(submitModel.ModelSearch.ToLower()));
            }

            if (submitModel.ManufSearch != null)
            {
                result = result.Where(x => x.Manufacturer.Name == submitModel.ManufSearch);
            }

            if (submitModel.PriceSearch != 0)
            {
                result = result.Where(x => x.Price < submitModel.PriceSearch);
            }
            if (submitModel.ManufSearch == "All")
            {
                result = this.Data.Smartphones.All();
            }
            var endResult = result.Select(x => new SmartphoneViewModel
            {
                Id = x.Id,
                Model = x.Model,
                Manufacturer = x.Manufacturer.Name,
                ImageUrl = x.ImageURL,
                Price = x.Price,
                Votes = x.Votes.Count(),
            });

            return View("ListAll",endResult);
        }