Exemplo n.º 1
0
        public ActionResult Search(string vinNumber)
        {
            if (string.IsNullOrEmpty(vinNumber))
            {
                return(RedirectToAction("InternalServer", "Error", new { area = "Error" }));
            }

            var carModel = this.service
                           .GetCarByVinNumber(vinNumber)
                           .ToList();
            var viewModel = new List <ShowAllCarsViewModel>();

            foreach (var car in carModel)
            {
                var currentUser = new ShowAllCarsViewModel()
                {
                    Id                 = car.Id,
                    Manufacturer       = car.Manufacturer,
                    Model              = car.Model,
                    RegistrationNumber = car.RegistrationNumber
                };

                viewModel.Add(currentUser);
            }

            if (viewModel.Count < 1)
            {
                return(PartialView("_NoResults", viewModel));
            }

            return(PartialView("_AllCars", viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var carModel = this.service
                           .GetAllCars()
                           .ToList();
            var viewModel = new List <ShowAllCarsViewModel>();

            foreach (var car in carModel)
            {
                var currentCar = new ShowAllCarsViewModel()
                {
                    Id                 = car.Id,
                    Manufacturer       = car.Manufacturer,
                    Model              = car.Model,
                    RegistrationNumber = car.RegistrationNumber
                };

                viewModel.Add(currentCar);
            }

            return(View(viewModel));
        }