示例#1
0
        public ActionResult AddVehicle(AdminAddVehicleCM form)
        {
            if (ModelState.IsValid)
            {
                Vehicles          vehicle   = new Vehicles();
                var               repo      = new VehicleRepositoryADO();
                var               modelRepo = new VehicleModelRepositoryADO();
                var               makeRepo  = new MakeRepositoryADO();
                AdminAddVehicleVM VM        = new AdminAddVehicleVM();
                vehicle.MakeId = form.MakeId;
                //vehicle.Make = form.Make;
                vehicle.ModelId = form.ModelId;
                //vehicle.Model = form.Model;
                vehicle.Vin          = form.Vin;
                vehicle.Year         = form.Year;
                vehicle.BodyStyle    = form.BodyStyle;
                vehicle.Transmission = form.Transmission;
                vehicle.Type         = form.Type == "new";
                vehicle.Mileage      = form.Mileage;
                vehicle.Color        = form.Color;
                vehicle.Interior     = form.Interior;
                vehicle.Msrp         = form.Msrp;
                vehicle.Description  = form.Description;
                vehicle.SalePrice    = form.SalePrice;
                VM.SetAvailableMakes(makeRepo.ReadAllMakes());
                VM.SetAvailableModels(modelRepo.ReadAllModel());
                VM.BodyStyles();
                VM.Colors();
                VM.Interiors();
                VM.Type();
                repo.CreateVehicle(vehicle);


                return(RedirectToAction("Vehicle"));
            }
            else
            {
                AdminAddVehicleVM VM = new AdminAddVehicleVM();
                var modelRepo        = new VehicleModelRepositoryADO();
                var makeRepo         = new MakeRepositoryADO();
                VM.SetAvailableMakes(makeRepo.ReadAllMakes());
                VM.SetAvailableModels(modelRepo.ReadAllModel());
                VM.BodyStyles();
                VM.Colors();
                VM.Interiors();
                VM.Type();

                VM.Form = form;
                return(View(VM));
            }
        }
示例#2
0
        public ActionResult AddVehicle()
        {
            AdminAddVehicleVM VM = new AdminAddVehicleVM();
            var repo             = new VehicleRepositoryADO();
            var modelRepo        = new VehicleModelRepositoryADO();
            var makeRepo         = new MakeRepositoryADO();

            VM.SetAvailableMakes(makeRepo.ReadAllMakes());
            VM.SetAvailableModels(modelRepo.ReadAllModel());
            VM.BodyStyles();
            VM.Colors();
            VM.Interiors();
            VM.Type();
            return(View(VM));
        }