Beispiel #1
0
        public ActionResult AddVehicle()
        {
            var LookupRepo = LookupValueFactory.GetRepository();
            var repo       = RepositoryFactory.GetRepository();
            var model      = new AddEditVehicleViewModel();

            //set lookup values
            model.SetBodyStyles(LookupRepo.GetBodyStyles());
            model.SetMakes(repo.GetMakes());
            model.SetCondition(LookupRepo.GetCondition());
            model.SetExteriorColor(LookupRepo.GetExteriorColor());
            model.SetInteriorColor(LookupRepo.GetInteriorColor());
            model.SetTransmissions(LookupRepo.GetTransmissionTypes());
            model.SetYears(LookupRepo.GetYears());

            return(View(model));
        }
Beispiel #2
0
        public ActionResult EditVehicle(int id)
        {
            var repo                     = RepositoryFactory.GetRepository();
            var LookupValueRepo          = LookupValueFactory.GetRepository();
            VehicleQueryModel       vcm  = repo.GetVehicleDetail(id);
            AddEditVehicleViewModel aevm = new AddEditVehicleViewModel();

            //Set lookup values
            aevm.SetBodyStyles(LookupValueRepo.GetBodyStyles());
            aevm.SetCondition(LookupValueRepo.GetCondition());
            aevm.SetExteriorColor(LookupValueRepo.GetExteriorColor());
            aevm.SetInteriorColor(LookupValueRepo.GetInteriorColor());
            aevm.SetMakes(repo.GetMakes());
            aevm.SetTransmissions(LookupValueRepo.GetTransmissionTypes());
            aevm.SetYears(LookupValueRepo.GetYears());

            //Get the models for the make of this vehicle
            aevm.SetModels(repo.GetModelsByMakeId(vcm.MakeId));

            // Translate the Vechicle Query model to the AddEditVehicleViewModel
            aevm.Condition     = vcm.ConditionType.ToString();
            aevm.Transmission  = vcm.TransmissionType.ToString();
            aevm.VIN           = vcm.VIN.ToString();
            aevm.Year          = vcm.Year;
            aevm.MSRP          = vcm.MSRP;
            aevm.SalePrice     = vcm.SalePrice;
            aevm.ModelId       = vcm.ModelId;
            aevm.MakeId        = vcm.MakeId;
            aevm.ImageFileName = vcm.ImageFileName.ToString();
            aevm.Mileage       = vcm.Mileage;
            aevm.InteriorColor = vcm.InteriorColor.ToString();
            aevm.ExteriorColor = vcm.ExteriorColor.ToString();
            aevm.Description   = vcm.Description.ToString();
            aevm.BodyStyle     = vcm.BodyStyle.ToString();
            aevm.VehicleId     = vcm.VehicleId;
            aevm.FeaturedFlag  = vcm.FeaturedFlag;
            aevm.UserId        = vcm.UserId;

            return(View(aevm));
        }