Exemplo n.º 1
0
        public async Task <IActionResult> GetProductGroup(string name, [FromQuery] string fields)
        {
            if (!_typeHelperService.TypeHasProperties <ProductGroupDto>(fields))
            {
                return(BadRequest());
            }

            if (!await _productGroupRepository.ProductGroupExists(name))
            {
                return(NotFound());
            }

            var productGroup = await _productGroupRepository.GetProductGroupByName(name);

            var productGroupToReturn = Mapper.Map <ProductGroupDto>(productGroup);

            return(Ok(productGroupToReturn.ShapeData(fields)));
        }