Esempio n. 1
0
 public ProductDTO addProduct(ProductDTO product)
 {
     if (productDataAccessProvider.GetProducts(p => p.ProductId == product.ProductId, false).Any())
     {
         throw new BusinessException("Product id already exists");
     }
     else if (productDataAccessProvider.GetProducts(p => p.Name == product.Name, false).Any())
     {
         throw new BusinessException("Product name already exists");
     }
     else
     {
         return(mapper.getDTO(productDataAccessProvider.AddProduct(mapper.getEntity(product, categoryDataAccessProvider.GetCategory(product.CategoryId)))));
     }
 }