diff --git a/LuminousSales/Business/Business/Sales/ProductController.cs b/LuminousSales/Business/Business/Sales/ProductController.cs index a05595e..4673858 100644 --- a/LuminousSales/Business/Business/Sales/ProductController.cs +++ b/LuminousSales/Business/Business/Sales/ProductController.cs @@ -347,6 +347,37 @@ namespace Business.Business.Sales } } + /// + /// Adds to the amount of a given product. + /// + /// + /// Requires no special roles. + /// + /// + /// Accepts the product name for getting the product and amount to add + /// + + public void AddAmount(string productName, double Amount) + { + if (currentUser.RoleId > 1) + { + var product = Get(productName); + if (product != null) + { + product.AmountInStock += Amount; + context.SaveChanges(); + } + else + { + throw new ArgumentException("Product name not valid!"); + } + } + else + { + throw new ArgumentException("Insufficient Role!"); + } + } + /// /// Subtracts to the amount of a given product. /// @@ -378,6 +409,37 @@ namespace Business.Business.Sales } } + /// + /// Subtracts to the amount of a given product. + /// + /// + /// Requires no special roles. + /// + /// + /// Accepts the product name for getting the product and amount to substract + /// + + public void RemoveAmount(string productName, double Amount) + { + if (currentUser.RoleId > 1) + { + var product = Get(productName); + if (product != null) + { + product.AmountInStock -= Amount; + context.SaveChanges(); + } + else + { + throw new ArgumentException("Product id not valid!"); + } + } + else + { + throw new ArgumentException("Insufficient Role!"); + } + } + /// /// Deletes the given product. ///