コード例 #1
0
        public ActionResult Details(string licensePlate)
        {
            Car car = CarRepository.RetrieveByLicensePlate(licensePlate);

            var viewData = new CarDetailsViewData
            {
                Car = car,
                TotalKilometers = CostsRepository.CalculateTotalKilometers(car),
                AverageUsage = CostsRepository.CalculateAverageUsage(car),
                TotalCosts = CostsRepository.CalculateTotalCosts(car),
                AverageCosts = CostsRepository.CalculateAverageCostsPerKilometer(car)
            };

            return View("Details", viewData);
        }
コード例 #2
0
        public ActionResult Statistics(string licensePlate)
        {
            if (!Request.IsAjaxRequest())
            {
                return RedirectToAction("Details", new { licensePlate = licensePlate });
            }

            Car car = CarRepository.RetrieveByLicensePlate(licensePlate);

            var viewData = new CarDetailsViewData
            {
                Car = car,
                TotalKilometers = CostsRepository.CalculateTotalKilometers(car),
                AverageUsage = CostsRepository.CalculateAverageUsage(car),
                TotalCosts = CostsRepository.CalculateTotalCosts(car),
                AverageCosts = CostsRepository.CalculateAverageCostsPerKilometer(car)
            };

            return View("StatisticsCarDetails", viewData);
        }