public OuterMostPartsViewModel GetPartsProductForHome() { PartsProductsCategoryRepository partsProductsCategoryRepository = new PartsProductsCategoryRepository(new AutoSolutionContext()); PartsSubCategoryRepository partsSubCategoryRepository = new PartsSubCategoryRepository(new AutoSolutionContext()); OuterMostPartsViewModel outerMostPartsViewModel = new OuterMostPartsViewModel() { OuterpartViewModelsList = AutoSolutionContext.PartsProductsCategories.Select(x => new OuterPartViewModel() { PartsProductsCategoryId = x.PartsProductsCategoryId, PartsProductsCategoryName = x.PartsProductsCategoryName, partInnerViewModelList = x.PartsProductsSubCategories.OrderBy(sub => sub.PartsProductsSubCategoryName).Select(y => new InnerPartViewModel() { PartsProductsSubCategoryId = y.PartsProductsSubCategoryId, PartsProductsSubCategoryName = y.PartsProductsSubCategoryName, }).ToList(), PartsProductsViewModelsList = (from sub in x.PartsProductsSubCategories join pp in AutoSolutionContext.PartsProducts on sub.PartsProductsSubCategoryId equals pp.PartsProductsSubCategoryId orderby pp.PartsProductName //where sub.PartsProductsSubCategoryId ==pp.PartsProductsSubCategoryId select new PartsProductsViewModel() { PartsProductId = pp.PartsProductId, PartsProductName = pp.PartsProductName, UnitPrice = pp.UnitPrice, ShortDescription = pp.ShortDescription, VehicleManufacturerName = pp.VehicleManufacturer.VehicleManufacturerName, VehicleModelName = pp.VehicleModel.VehicleModelName, startYear = pp.startYear, EndYear = pp.EndYear }).Take(8).ToList() }).ToList() }; return(outerMostPartsViewModel); }
public ActionResult GetPartsProductForHome() { OuterMostPartsViewModel model = _unitOfWork.PartsProducts.GetPartsProductForHome(); return(PartialView("_GetPartsProduct", model)); }