Exemplo n.º 1
0
        public async Task <Product> CreateProductAsync(CreateProductDto createProductDto)
        {
            var validationResults = createProductDto.Validate();
            var validations       = validationResults.ToList();

            if (validations.Any())
            {
                throw new ValidationException(validations);
            }

            var product = new Product
            {
                Id            = Guid.NewGuid(),
                DeliveryPrice = createProductDto.DeliveryPrice,
                Name          = createProductDto.Name,
                Description   = createProductDto.Description,
                Price         = createProductDto.Price
            };

            return(await _repository.CreateAsync(product));
        }