Пример #1
0
 public async Task UpdateProductAsync(CreateProductDTO product)
 {
     if (Get(product.Id) == null)
     {
         throw new Exception("Taki produkt nie istnieje");
     }
     else
     {
         Shop.Core.Domain.Product model = new Shop.Core.Domain.Product(product.Id, product.Name, product.Description, product.Price, product.Quantity, product.CategoryId);
         await productRepository.UpdateProductAsync(model);
     }
 }
Пример #2
0
        public async Task AddProduct(CreateProductDTO product)
        {
            var item = await Get(product.Id);

            if (item != null)
            {
                throw new Exception("Taki produkt już istnieje");
            }
            else
            {
                Shop.Core.Domain.Product model = new Shop.Core.Domain.Product(product.Id, product.Name, product.Description, product.Price, product.Quantity, product.CategoryId);
                await productRepository.AddProduct(model);
            }
        }