public PartsProductsViewModel AddNewPartsProducts() { 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() { VehicleManufacturerList = vehicleModelRepository.GetVehicleManufacturerDropDown(), PartsProductsCategoryList = partsSubCategoryRepository.GetPartsProductCategoryDropDown(), PartsProductsSubCategoryList = partsSubCategoryRepository.GetPartsProductSubCategoryDropDownEmpty(), PartProductManufacturerList = partsProductManufacturerRepository.GetPPManufacturerDropDownEmpty(), VehicleModelList = vehicleModelRepository.GetVehicleModelDropDownEmpty(), //TransmissionTypeList = transmissionTypeRepository.GetTransmissionTypeDownEmpty(), //EngineTypeList = vehicleEngineTypeRepository.GetVehicleEngineTypeDropDownEmpty(), }; return(partsProductsViewModel); }
public PartProductwraperForHome GetPartsProducts(int PageNo, int TotalCount, int id) { VehicleModelRepository vehicleModelRepository = new VehicleModelRepository(new AutoSolutionContext()); PartsSubCategoryRepository partsSubCategoryRepository = new PartsSubCategoryRepository(new AutoSolutionContext()); PartProductwraperForHome partProductwraperForHome = new PartProductwraperForHome() { FindYourPart = { VehicleManufacturersList = vehicleModelRepository.GetVehicleManufacturerDropDownForHome(), VehicleModelsList = vehicleModelRepository.GetVehicleModelDropDownEmptyForHome(), PartsProductsCategoryList = partsSubCategoryRepository.GetPartsProductCategoryDropDown(), PartsProductsSubCategoryList = partsSubCategoryRepository.GetPartsProductSubCategoryDropDownEmpty() }, PartsProductsCategory = AutoSolutionContext.PartsProductsCategories.Where(x => x.PartsProductsCategoryId == id).FirstOrDefault(), PartsProductsViewModelsList = (from ppsc in AutoSolutionContext.PartsProductsSubCategories join pp in AutoSolutionContext.PartsProducts on ppsc.PartsProductsSubCategoryId equals pp.PartsProductsSubCategoryId where id == ppsc.PartsProductsCategoryId orderby pp.AddedDate select new PartsProductsViewModel() { PartsProductName = pp.PartsProductName, UnitPrice = pp.UnitPrice, ShortDescription = pp.ShortDescription, VehicleManufacturerName = pp.VehicleManufacturer.VehicleManufacturerName, VehicleModelName = pp.VehicleModel.VehicleModelName, startYear = pp.startYear, EndYear = pp.EndYear }).Skip((PageNo - 1) * 12).Take(12).ToList(), Pager = new Pager(TotalCount, PageNo, 12) }; return(partProductwraperForHome); }