예제 #1
0
        public ActionResult EditVehicle(int id)
        {
            var repo = VehicleRepoFactory.CreateVehicleRepo();
            AddEditVehicleVM editVehicleVM = new AddEditVehicleVM();

            editVehicleVM.vehicle = repo.GetVehicleById(id);

            editVehicleVM.BodyStyle    = GetBodyStylesSelectList();
            editVehicleVM.Color        = GetColorsSelectList();
            editVehicleVM.Interior     = GetInteriorsSelectList();
            editVehicleVM.Make         = GetMakeSelectList();
            editVehicleVM.Model        = GetModelSelectList();
            editVehicleVM.Transmission = GetTransmissionSelectList();

            editVehicleVM.MakeName         = editVehicleVM.vehicle.MakeName;
            editVehicleVM.ModelName        = editVehicleVM.vehicle.ModelName;
            editVehicleVM.BodyStyleName    = editVehicleVM.vehicle.BodyStyleName;
            editVehicleVM.TransmissionName = editVehicleVM.vehicle.TransmissionType;
            editVehicleVM.ColorName        = editVehicleVM.vehicle.ColorName;
            editVehicleVM.InteriorName     = editVehicleVM.vehicle.InteriorType;
            editVehicleVM.Year             = editVehicleVM.vehicle.ModelYear;
            editVehicleVM.Mileage          = editVehicleVM.vehicle.Mileage;
            editVehicleVM.VIN         = editVehicleVM.vehicle.VIN;
            editVehicleVM.Type        = editVehicleVM.vehicle.New;
            editVehicleVM.Featured    = editVehicleVM.vehicle.Featured;
            editVehicleVM.Description = editVehicleVM.vehicle.VehicleDescription;
            editVehicleVM.MSRP        = editVehicleVM.vehicle.MSRP;
            editVehicleVM.SalePrice   = editVehicleVM.vehicle.SalePrice;


            return(View(editVehicleVM));
        }
예제 #2
0
        public ActionResult AddVehicle(AddEditVehicleVM addVehicleVM)
        {
            VehicleUI vehicle = new VehicleUI();
            var       repo    = VehicleRepoFactory.CreateVehicleRepo();

            if (ModelState.IsValid)
            {
                vehicle.MakeName         = addVehicleVM.MakeName;
                vehicle.ModelName        = addVehicleVM.ModelName;
                vehicle.BodyStyleName    = addVehicleVM.BodyStyleName;
                vehicle.TransmissionType = addVehicleVM.TransmissionName;
                vehicle.ColorName        = addVehicleVM.ColorName;
                vehicle.InteriorType     = addVehicleVM.InteriorName;
                vehicle.ModelYear        = addVehicleVM.Year;
                vehicle.Mileage          = addVehicleVM.Mileage;
                vehicle.VIN                = addVehicleVM.VIN;
                vehicle.New                = addVehicleVM.Type;
                vehicle.Featured           = addVehicleVM.Featured;
                vehicle.VehicleDescription = addVehicleVM.Description;
                vehicle.MSRP               = addVehicleVM.MSRP;
                vehicle.SalePrice          = addVehicleVM.SalePrice;

                repo.InsertVehicle(vehicle);

                if (addVehicleVM.UploadedImage != null && addVehicleVM.UploadedImage.ContentLength > 0)
                {
                    string extension = Path.GetExtension(addVehicleVM.UploadedImage.FileName);
                    string path      = Path.Combine(Server.MapPath("~/Images"),
                                                    Path.GetFileName("inventory-" + vehicle.VehicleId + extension));

                    string fileName = Path.GetFileName("inventory-" + vehicle.VehicleId + extension);

                    addVehicleVM.UploadedImage.SaveAs(path);

                    vehicle.ImageFileName = fileName;

                    // maybe helpful blog post? https://asp-net-example.blogspot.in/2009/01/aspnet-fileupload-example-how-to-rename.html
                    //FileUpload FileUpload1 = new FileUpload();
                    //

                    //FileUpload1.SaveAs("~/Images/inventory" + vehicle.VehicleId + extension);
                }

                repo.UpdateVehicle(vehicle);

                return(RedirectToAction("EditVehicle/" + vehicle.VehicleId, "Admin"));
            }
            else
            {
                addVehicleVM.BodyStyle    = GetBodyStylesSelectList();
                addVehicleVM.Color        = GetColorsSelectList();
                addVehicleVM.Interior     = GetInteriorsSelectList();
                addVehicleVM.Make         = GetMakeSelectList();
                addVehicleVM.Model        = GetModelSelectList();
                addVehicleVM.Transmission = GetTransmissionSelectList();

                return(View(addVehicleVM));
            }
        }
예제 #3
0
        // GET: Sales
        public ActionResult Index()
        {
            var repo = VehicleRepoFactory.CreateVehicleRepo();

            List <VehicleUI> vehicles = repo.GetUnsoldVehicles();

            return(View(vehicles));
        }
예제 #4
0
        public ActionResult DeleteVehicle(int id)
        {
            var repo = VehicleRepoFactory.CreateVehicleRepo();

            repo.DeleteVehicle(id);

            return(RedirectToAction("Index", "Admin"));
        }
예제 #5
0
        public ActionResult Details(int id)
        {
            var repo = VehicleRepoFactory.CreateVehicleRepo();

            VehicleUI vehicle = repo.GetVehicleById(id);



            return(View(vehicle));
        }
예제 #6
0
        public ActionResult Index()
        {
            var vehicleRepo = VehicleRepoFactory.CreateVehicleRepo();
            var miscRepo    = MiscRepoFactory.CreateMiscRepo();

            HomeVM homeVM = new HomeVM();

            homeVM.Vehicles = vehicleRepo.GetFeaturedVehicles();
            homeVM.Specials = miscRepo.GetSpecials();

            return(View(homeVM));
        }
예제 #7
0
        public ActionResult Details(int id)
        {
            var vehicleRepo = VehicleRepoFactory.CreateVehicleRepo();

            MakeSaleVM makeSaleVM = new MakeSaleVM();

            makeSaleVM.Vehicle         = vehicleRepo.GetVehicleById(id);
            makeSaleVM.States          = GetStatesSelectList();
            makeSaleVM.PurchaseMethods = GetPurchaseTypesSelectList();

            return(View(makeSaleVM));
        }