Exemplo n.º 1
0
        public IQueryable <MobilePhone> GetMobilePhonesByManufacturer(int manufacturerID)
        {
            var mobiles = from x in _mobilePhoneService.GetAll()
                          where x.ManufacturerID == manufacturerID
                          select x;

            return(mobiles);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index(MobileSearchModel mobileSearchModel, int page = 1)
        {
            if (mobileSearchModel == null)
            {
                var items = _service.GetAll(true, true);
                var model = await PaginatedList <MobilePhone> .CreateAsync(items, page, 6);

                return(View(model));
            }

            ViewData["name"]           = mobileSearchModel.Name;
            ViewData["startPrice"]     = mobileSearchModel.StartPrice;
            ViewData["endPrice"]       = mobileSearchModel.EndPrice;
            ViewData["manufacturerID"] = mobileSearchModel.ManufacturerID;

            var filteredItems = _service.Search(mobileSearchModel.Name, mobileSearchModel.StartPrice, mobileSearchModel.EndPrice, mobileSearchModel.ManufacturerID);
            var filteredModel = await PaginatedList <MobilePhone> .CreateAsync(filteredItems, page, 6);

            return(View("Index", filteredModel));
        }