public ActionResult ManageAll(CarSpecificationViewModel model, int carId)
        {
            Car car = db.CarSet.Find(carId);
            ICollection <CarDetail> carSpecification = db.CarSet.Find(carId).CarDetails;
            CarDetail carDetail;

            if (carSpecification.Any(o => o.Type == CarDetailType.GasTankCapacity))
            {
                carDetail                 = carSpecification.Single(detail => detail.Type == CarDetailType.GasTankCapacity);
                carDetail.Value           = model.GasTankCapacity.Value;
                db.Entry(carDetail).State = EntityState.Modified;
            }
            else
            {
                model.GasTankCapacity.Car = car;
                db.CarDetailSet.Add(model.GasTankCapacity);
            }


            if (carSpecification.Any(o => o.Type == CarDetailType.EnginePower))
            {
                carDetail                 = carSpecification.Single(detail => detail.Type == CarDetailType.EnginePower);
                carDetail.Value           = model.EnginePower.Value;
                db.Entry(carDetail).State = EntityState.Modified;
            }
            else
            {
                model.EnginePower.Car = car;
                db.CarDetailSet.Add(model.EnginePower);
            }

            if (carSpecification.Any(o => o.Type == CarDetailType.FuelConsumption))
            {
                carDetail                 = carSpecification.Single(detail => detail.Type == CarDetailType.FuelConsumption);
                carDetail.Value           = model.FuelConsumption.Value;
                db.Entry(carDetail).State = EntityState.Modified;
            }
            else
            {
                model.FuelConsumption.Car = car;
                db.CarDetailSet.Add(model.FuelConsumption);
            }

            db.SaveChanges();

            return(RedirectToAction("Details", "Cars", new { id = carId }));
        }
        // GET: CarDetails/ManageAll
        public ActionResult ManageAll(int?carId)
        {
            CarSpecificationViewModel cs;

            if (carId.HasValue)
            {
                ViewBag.carId = carId;
                var car = db.CarSet.Find(carId.Value);
                cs = new CarSpecificationViewModel(car);
            }
            else
            {
                cs = new CarSpecificationViewModel();
            }

            return(View(cs));
        }