Controllers updates
This commit is contained in:
@@ -328,22 +328,15 @@ namespace Business.Business.Sales
|
|||||||
|
|
||||||
public void AddAmount(int productId ,double Amount)
|
public void AddAmount(int productId ,double Amount)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
var product = Get(productId);
|
||||||
|
if (product != null)
|
||||||
{
|
{
|
||||||
var product = Get(productId);
|
product.AmountInStock += Amount;
|
||||||
if (product != null)
|
context.SaveChanges();
|
||||||
{
|
|
||||||
product.AmountInStock += Amount;
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Product id not valid!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
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)
|
public void AddAmount(string productName, double Amount)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
var product = Get(productName);
|
||||||
|
if (product != null)
|
||||||
{
|
{
|
||||||
var product = Get(productName);
|
product.AmountInStock += Amount;
|
||||||
if (product != null)
|
context.SaveChanges();
|
||||||
{
|
|
||||||
product.AmountInStock += Amount;
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Product name not valid!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Insufficient Role!");
|
throw new ArgumentException("Product name not valid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Subtracts to the amount of a given product.
|
/// Subtracts to the amount of a given product.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -414,22 +399,15 @@ namespace Business.Business.Sales
|
|||||||
|
|
||||||
public void RemoveAmount(string productName, double Amount)
|
public void RemoveAmount(string productName, double Amount)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
var product = Get(productName);
|
||||||
|
if (product != null)
|
||||||
{
|
{
|
||||||
var product = Get(productName);
|
product.AmountInStock -= Amount;
|
||||||
if (product != null)
|
context.SaveChanges();
|
||||||
{
|
|
||||||
product.AmountInStock -= Amount;
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Product id not valid!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Insufficient Role!");
|
throw new ArgumentException("Product id not valid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user