public ActionResult Edit(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var item          = _unitOfWork.PartsProducts.GetByID(Convert.ToInt32(id));
                var VManufacturer = _unitOfWork.VehicleManufacturer.GetByID(item.VehicleModel.VehicleManufacturerId);
                var VModel        = _unitOfWork.VehicleModel.GetByID(item.VehicleModel.VehicleModelId);
                var PSUbCategory  = _unitOfWork.PartsSubCategory.GetByID(item.PartsProductsSubCategoryId);
                var PCategory     = _unitOfWork.PartsProductsCategory.GetByID(item.PartsProductsSubCategory.PartsProductsCategoryId);
                var PManufacturer = _unitOfWork.PartsProductManufacturer.GetByID(item.PartsProductManufacturer.PartsProductManufacturerId);
                VehicleModelRepository             vehicleModelRepository             = new VehicleModelRepository(new AutoSolutionContext());
                PartsSubCategoryRepository         partsSubCategoryRepository         = new PartsSubCategoryRepository(new AutoSolutionContext());
                TransmissionTypeRepository         transmissionTypeRepository         = new TransmissionTypeRepository(new AutoSolutionContext());
                VehicleEngineTypeRepository        vehicleEngineTypeRepository        = new VehicleEngineTypeRepository(new AutoSolutionContext());
                PartsProductManufacturerRepository partsProductManufacturerRepository = new PartsProductManufacturerRepository(new AutoSolutionContext());

                PartsProductsViewModel partsProductsViewModel = new PartsProductsViewModel();
                partsProductsViewModel.PartsProductId   = item.PartsProductId;
                partsProductsViewModel.EndYear          = item.EndYear;
                partsProductsViewModel.startYear        = item.startYear;
                partsProductsViewModel.PartsProductName = item.PartsProductName;
                partsProductsViewModel.LongDescription  = item.LongDescription;
                partsProductsViewModel.ShortDescription = item.ShortDescription;
                partsProductsViewModel.UnitPrice        = item.UnitPrice;


                partsProductsViewModel.VehicleManufacturerList      = vehicleModelRepository.GetVehicleManufacturerDropDown();
                partsProductsViewModel.VehicleModelList             = vehicleModelRepository.GetVehicleModelDropDown();
                partsProductsViewModel.PartsProductsCategoryList    = partsSubCategoryRepository.GetPartsProductCategoryDropDown();
                partsProductsViewModel.PartsProductsSubCategoryList = partsSubCategoryRepository.GetPartsProductSubCategoryDropDown();
                partsProductsViewModel.PartProductManufacturerList  = partsProductManufacturerRepository.GetPPManufacturerDropDown();


                partsProductsViewModel.SelectedManufacturer            = VManufacturer.VehicleManufacturerId;
                partsProductsViewModel.SelectedModel                   = VModel.VehicleModelId;
                partsProductsViewModel.SelectedPartsProductCategory    = PCategory.PartsProductsCategoryId.ToString();
                partsProductsViewModel.SelectedPartsProductSubCategory = PSUbCategory.PartsProductsSubCategoryId.ToString();
                partsProductsViewModel.SelectedPartProductManufacturer = PManufacturer.PartsProductManufacturerId.ToString();
                partsProductsViewModel.SelectedModel                   = item.VehicleModelId;

                partsProductsViewModel.PartProductImagesList = item.PartProductImages.ToList();
                if (partsProductsViewModel != null)
                {
                    return(PartialView("_EditPartsProduct", partsProductsViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult Edit(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var item = _unitOfWork.VehicleModel.GetByID(Convert.ToInt32(id));
                VehilceModelViewModel  vehilceModelViewModel  = new VehilceModelViewModel();
                VehicleModelRepository vehicleModelRepository = new VehicleModelRepository(new AutoSolutionContext());
                vehilceModelViewModel.VehicleModelId = item.VehicleModelId;
                vehilceModelViewModel.VehicleModel   = item.VehicleModelName;
                //               vehilceModelViewModel.YearOfManufacture = item.YearOfManufacture;
                vehilceModelViewModel.SelectedVehicleManufacturer = item.VehicleManufacturerId.ToString();
                vehilceModelViewModel.VehicleManufacturersList    = vehicleModelRepository.GetVehicleManufacturerDropDown();
                if (vehilceModelViewModel != null)
                {
                    return(PartialView("_EditVehicleModel", vehilceModelViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        public ActionResult Edit(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var item         = _unitOfWork.VehicleVersion.GetByID(Convert.ToInt32(id));
                var Manufacturer = _unitOfWork.VehicleManufacturer.GetByID(item.VehicleModel.VehicleManufacturerId);

                VehicleVersionViewModel     vehicleVersionViewModel     = new VehicleVersionViewModel();
                VehicleModelRepository      vehicleModelRepository      = new VehicleModelRepository(new AutoSolutionContext());
                VehicleEngineTypeRepository vehicleEngineTypeRepository = new VehicleEngineTypeRepository(new AutoSolutionContext());
                TransmissionTypeRepository  transmissionTypeRepository  = new TransmissionTypeRepository(new AutoSolutionContext());

                vehicleVersionViewModel.VehicleVersionId        = item.VehicleVersionId;
                vehicleVersionViewModel.VehicleVersionName      = item.VehicleVersionName;
                vehicleVersionViewModel.EngineCapacity          = item.EngineCapacity;
                vehicleVersionViewModel.startYear               = item.startYear;
                vehicleVersionViewModel.EndYear                 = item.EndYear;
                vehicleVersionViewModel.VehicleManufacturerList = vehicleModelRepository.GetVehicleManufacturerDropDown();
                vehicleVersionViewModel.VehicleModelList        = vehicleModelRepository.GetVehicleModelDropDown();
                vehicleVersionViewModel.TransmissionTypeList    = transmissionTypeRepository.GetTransmissionDropDown();
                vehicleVersionViewModel.EngineTypeList          = vehicleEngineTypeRepository.GetVehicleEngineTypeDropDown();

                vehicleVersionViewModel.SelectedManufacturer     = Manufacturer.VehicleManufacturerId.ToString();
                vehicleVersionViewModel.SelectedEngineType       = item.VehicleEngineTypeId.ToString();
                vehicleVersionViewModel.SelectedModel            = item.VehicleModelId.ToString();
                vehicleVersionViewModel.SelectedTransmissionType = item.TransmissionTypeId.ToString();
                if (vehicleVersionViewModel != null)
                {
                    return(PartialView("_EditVehicleVersion", vehicleVersionViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }