public void GetAndSetDataCorrectly(int testId)
        {
            // Arrange and Act
            var viewModel = new AdvertSearchViewModel { CityId = testId };

            // Assert
            Assert.AreEqual(testId, viewModel.CityId);
        }
        public void GetAndSetDataCorrectly(int test)
        {
            // Arrange and Act
            var viewModel = new AdvertSearchViewModel {
                MaxPrice = test
            };

            // Assert
            Assert.AreEqual(test, viewModel.MaxPrice);
        }
        public void GetAndSetDataCorrectly(int test)
        {
            // Arrange and Act
            var viewModel = new AdvertSearchViewModel {
                MinDistanceCoverage = test
            };

            // Assert
            Assert.AreEqual(test, viewModel.MinDistanceCoverage);
        }
        public ActionResult Index(AdvertSearchViewModel model)
        {
            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!this.ModelState.IsValid)
            {
                this.TempData["Notification"] = "Exception.";

                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                // FIX THIIS
                var adverts = advertService.Search(
                    model.VehicleModelId,
                    model.CityId,
                    model.MinYear,
                    model.MaxYear,
                    model.MinPrice,
                    model.MaxPrice,
                    model.MinPower,
                    model.MaxPower,
                    model.MinDistanceCoverage,
                    model.MaxDistanceCoverage)
                              .OrderBy(a => a.Id)
                              .ProjectTo <AdvertDetailViewModel>().ToList();

                return(View(adverts));
            }

            catch (Exception e)
            {
                this.TempData["Notification"] = "Exception.";

                return(RedirectToAction("Index", "Home"));
            }
        }