Esempio n. 1
0
        public async Task AddAsync(Guid id, string name, int amount, decimal price, string producerName, string categoryName, string brandTag, string descryption)
        {
            var @product = await _productRepository.GetAsync(name);

            var @producer = await _producerRepository.SetOrGetExistingAsync(producerName);

            var @category = await _categoryRepository.GetAsync(categoryName);

            if (@category == null)
            {
                throw new Exception($"Cannot find category with '{categoryName}' ");
            }
            @product = new Product(id, name, amount, price, @producer.Name, @producer.Id, @category.Name, @category.Id, descryption, brandTag);
            await _productRepository.AddAsync(@product);
        }