diff --git a/LuminousSales/Business/Business/Sales/ProductController.cs b/LuminousSales/Business/Business/Sales/ProductController.cs index 0b01c1a..370abef 100644 --- a/LuminousSales/Business/Business/Sales/ProductController.cs +++ b/LuminousSales/Business/Business/Sales/ProductController.cs @@ -328,22 +328,15 @@ namespace Business.Business.Sales public void AddAmount(int productId ,double Amount) { - if (currentUser.RoleId > 1) + var product = Get(productId); + if (product != null) { - var product = Get(productId); - if (product != null) - { - product.AmountInStock += Amount; - context.SaveChanges(); - } - else - { - throw new ArgumentException("Product id not valid!"); - } + product.AmountInStock += Amount; + context.SaveChanges(); } else { - throw new ArgumentException("Insufficient Role!"); + throw new ArgumentException("Product id not valid!"); } } @@ -359,25 +352,17 @@ namespace Business.Business.Sales public void AddAmount(string productName, double Amount) { - if (currentUser.RoleId > 1) + var product = Get(productName); + if (product != null) { - var product = Get(productName); - if (product != null) - { - product.AmountInStock += Amount; - context.SaveChanges(); - } - else - { - throw new ArgumentException("Product name not valid!"); - } + product.AmountInStock += Amount; + context.SaveChanges(); } else { - throw new ArgumentException("Insufficient Role!"); + throw new ArgumentException("Product name not valid!"); } } - /// /// Subtracts to the amount of a given product. /// @@ -414,22 +399,15 @@ namespace Business.Business.Sales public void RemoveAmount(string productName, double Amount) { - if (currentUser.RoleId > 1) + var product = Get(productName); + if (product != null) { - var product = Get(productName); - if (product != null) - { - product.AmountInStock -= Amount; - context.SaveChanges(); - } - else - { - throw new ArgumentException("Product id not valid!"); - } + product.AmountInStock -= Amount; + context.SaveChanges(); } else { - throw new ArgumentException("Insufficient Role!"); + throw new ArgumentException("Product id not valid!"); } }