public Task <List <CategoryAttributeFullInfoView> > Handle(GetCategoryAttributesWithValuesQuery request, CancellationToken cancellationToken) => Task.Run(() => { var attributes = _categoryService.GetAllCategoryAttributesByCategoryId(request.CategoryId); var attributeMappings = _categoryService.GetCategoryAttributeMappingsByCategoryId(request.CategoryId); var mappedAttributes = AutoMapperConfiguration.Mapper.Map <List <CategoryAttributeFullInfoView> >(attributes); mappedAttributes.ForEach(attribute => { var attributeMapping = attributeMappings.FirstOrDefault(x => x.CategoryAttributeId == attribute.Id); attribute = AutoMapperConfiguration.Mapper.Map(attributeMapping, attribute); attribute.Values = AutoMapperConfiguration.Mapper.Map <IEnumerable <CategoryAttributeValueView> >(_categoryService.GetCategoryAttributeValues(attributeMapping.Id)); }); return(mappedAttributes); }, cancellationToken);
public async Task <ActionResult <List <CategoryAttributeFullInfoView> > > Attributes([FromQuery] GetCategoryAttributesWithValuesQuery query) => Result(await SendAsync(query));