Пример #1
0
        public void CarControllerDetailsTest()
        {
            CarController carController = new CarController();
            ActionResult  actionResult  = carController.Details(1);

            Assert.IsInstanceOfType(actionResult, typeof(ActionResult));

            ViewResult viewResult = actionResult as ViewResult;

            Assert.IsInstanceOfType(viewResult.Model, typeof(VMCar));
            VMCar car = viewResult.Model as VMCar;

            Assert.AreEqual("Bill Ford", car.OwnerName);
        }
Пример #2
0
        // GET: Car/Details/5
        public ActionResult Details(int id)
        {
            int index = cars.FindIndex(c => c.ID == id);

            if (index == -1)
            {
                return(View("Error", new ErrorViewModel {
                    Description = $"Car with ID {id} not found."
                }));
            }

            Owner owner = owners[index];
            Car   car   = cars[index];
            VMCar vmCar = new VMCar {
                ID = car.ID, Make = car.Make, Model = car.Model, Year = car.Year, Email = car.Email
            };

            vmCar.OwnerName = $"{owner.FirstName} {owner.LastName}";
            return(View(vmCar));
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                AppViewBackButtonVisibility.Collapsed;
            // Carga la lista de ModelView a partir de la lista de Modelo
            if (ListaCoches != null)
            {
                foreach (CarID currCar in CarModel.GetAllCars())
                {
                    VMCar VMitem = new VMCar(currCar);
                    //VMitem.Nombre = logro.Nombre;
                    ListaCoches.Add(VMitem);
                    if (VMitem.Estado == CarID.estados.bloqueado)
                    {
                    }
                }
            }

            listaCoches_.ItemsSource = ListaCoches;

            if (e.Parameter is bool)
            {
                permitirCompra = (bool)e.Parameter;
            }

            if (permitirCompra)
            {
                BotonJugar.Visibility = Visibility.Collapsed;
            }

            DineroText.Text = "DINERO: " + Money.ToString() + "€";

            ActualizaDatos();

            base.OnNavigatedTo(e);
        }