public async Task <List <ProductCategoriesAttributeViewModel> > GetDetailAttributeValues(string tenantId, string languageId, int categoryId) { var items = await _productCategoriesAttributeRepository.GetDetailAttributeValues(tenantId, languageId, categoryId); var proCateInfo = await _productCategoryRepository.GetInfo(categoryId); if (proCateInfo == null) { return(items); } foreach (var id in proCateInfo.IdPath.Split(".")) { items.AddRange(await _productCategoriesAttributeRepository.GetDetailAttributeValues(tenantId, languageId, Convert.ToInt32(id))); } var result = from item in items group item by new { item.AttributeId, item.AttributeName } into g select new ProductCategoriesAttributeViewModel { AttributeId = g.Key.AttributeId, AttributeName = g.Key.AttributeName, CategoryId = categoryId }; return(result.ToList()); }
public async Task <ActionResultResponse <ProductCategoryDetailViewModel> > GetDetail(string tenantId, string languageId, int id) { var productCategoryInfo = await _productCategoryRepository.GetInfo(id, true); if (productCategoryInfo == null) { return(new ActionResultResponse <ProductCategoryDetailViewModel>(-1, _productResourceService.GetString("Product category does not exists."))); } if (productCategoryInfo.TenantId != tenantId) { return(new ActionResultResponse <ProductCategoryDetailViewModel>(-2, _productResourceService.GetString(ErrorMessage.SomethingWentWrong))); } var productCategoryDetail = new ProductCategoryDetailViewModel { IsActive = productCategoryInfo.IsActive, IsHomePage = productCategoryInfo.IsHomePage, Image = productCategoryInfo.Image, IsHot = productCategoryInfo.IsHot, IsSolution = productCategoryInfo.IsSolution, ParentId = productCategoryInfo.ParentId, Order = productCategoryInfo.Order, ConcurrencyStamp = productCategoryInfo.ConcurrencyStamp, ChildCount = productCategoryInfo.ChildCount, Translations = await _productCategoryTranslationRepository.GetsByProductCategoryId(productCategoryInfo.Id), ProductCategoryAttributes = await _productCategoriesAttributeRepository.GetDetailAttributeValues(tenantId, languageId, productCategoryInfo.Id) }; return(new ActionResultResponse <ProductCategoryDetailViewModel> { Code = 1, Data = productCategoryDetail }); }