Views, Add Time in Deal & Stock
This commit is contained in:
@@ -9,8 +9,8 @@ namespace Business.Business.Sales
|
||||
ICollection<T> GetAll();
|
||||
T Get(int id);
|
||||
ICollection<T> GetByTime(DateTime startTime, DateTime endTime);
|
||||
void Add(int productId, double Amount);
|
||||
void Add(string productName, double Amount);
|
||||
void Add(int productId, double Amount, DateTime time);
|
||||
void Add(string productName, double Amount, DateTime time);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,11 @@ namespace Business.Business.Sales
|
||||
{
|
||||
this.currentUser = currentUser;
|
||||
}
|
||||
public void Add(int productId, double Amount)
|
||||
public void Add(int productId, double Amount, DateTime time)
|
||||
{
|
||||
if (Amount > 0)
|
||||
{
|
||||
var deal = new Deal(currentUser.Id, productId, Amount);
|
||||
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||
context.Deal.Add(deal);
|
||||
context.SaveChanges();
|
||||
}
|
||||
@@ -30,17 +30,16 @@ namespace Business.Business.Sales
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string productName, double Amount)
|
||||
public void Add(string productName, double Amount, DateTime time)
|
||||
{
|
||||
if (Amount > 0)
|
||||
{
|
||||
productCtrl = new ProductController(currentUser);
|
||||
var productId = productCtrl.Get(productName).Id;
|
||||
var deal = new Deal(currentUser.Id, productId, Amount);
|
||||
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||
context.Deal.Add(deal);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Amount cannot be negative");
|
||||
|
@@ -56,13 +56,15 @@ namespace Business.Business.Sales
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(int productId, double Amount)
|
||||
public void Add(int productId, double Amount, DateTime time)
|
||||
{
|
||||
if (currentUser.RoleId > 1)
|
||||
{
|
||||
if (Amount > 0)
|
||||
{
|
||||
var stock = new Stock(currentUser.Id, productId, Amount);
|
||||
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||
productCtrl = new ProductController(currentUser);
|
||||
productCtrl.Get(productId).AmountInStock += Amount;
|
||||
context.Stock.Add(stock);
|
||||
context.SaveChanges();
|
||||
}
|
||||
@@ -78,7 +80,7 @@ namespace Business.Business.Sales
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string productName, double Amount)
|
||||
public void Add(string productName, double Amount, DateTime time)
|
||||
{
|
||||
if (currentUser.RoleId > 1)
|
||||
{
|
||||
@@ -86,7 +88,8 @@ namespace Business.Business.Sales
|
||||
{
|
||||
productCtrl = new ProductController(currentUser);
|
||||
var productId = productCtrl.Get(productName).Id;
|
||||
var stock = new Stock(currentUser.Id, productId, Amount);
|
||||
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||
productCtrl.Get(productId).AmountInStock += Amount;
|
||||
context.Stock.Add(stock);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
Reference in New Issue
Block a user