Esempio n. 1
0
        public async Task <ProductDto> GetProductByIdAsync(long id)
        {
            var product = await _productRepository.GetByIdAsync(id);

            var result = ProductMapper.EntityToDtoMap(product);

            return(result);
        }
Esempio n. 2
0
        public async Task <ProductDto> SaveProductAsync(ProductDto product)
        {
            var entity = ProductMapper.DtoToEntityMap(product);

            if (!await _productValidationService.Validate(entity))
            {
                throw new ValidationException("The product didn't pass validation");
            }

            entity = await _productRepository.InsertAsync(entity);

            return(ProductMapper.EntityToDtoMap(entity));
        }