ProductController added name item adding
This commit is contained in:
@@ -347,6 +347,37 @@ namespace Business.Business.Sales
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds to the amount of a given product.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Requires no special roles.
|
||||
/// </remarks>
|
||||
/// <remarks>
|
||||
/// Accepts the product name for getting the product and amount to add
|
||||
/// </remarks>
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts to the amount of a given product.
|
||||
/// </summary>
|
||||
@@ -378,6 +409,37 @@ namespace Business.Business.Sales
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts to the amount of a given product.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Requires no special roles.
|
||||
/// </remarks>
|
||||
/// <remarks>
|
||||
/// Accepts the product name for getting the product and amount to substract
|
||||
/// </remarks>
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the given product.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user