Updates Comments
This commit is contained in:
@@ -10,21 +10,91 @@ namespace Business.Business.Sales
|
|||||||
{
|
{
|
||||||
public class DealController : ISalesController<Deal>
|
public class DealController : ISalesController<Deal>
|
||||||
{
|
{
|
||||||
private LuminousContext context = new LuminousContext();
|
private LuminousContext context;
|
||||||
private User currentUser;
|
private User currentUser;
|
||||||
private ProductController productCtrl;
|
private ProductController productctrl;
|
||||||
private UserController userctrl;
|
private UserController userctrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor that accepts a user object
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// User object is used for role checking
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public DealController(User currentUser)
|
public DealController(User currentUser)
|
||||||
{
|
{
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.productCtrl = new ProductController(currentUser);
|
this.context = new LuminousContext();
|
||||||
|
this.productctrl = new ProductController(currentUser);
|
||||||
this.userctrl = new UserController(currentUser);
|
this.userctrl = new UserController(currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor that accepts custom context, ProductController, UserController and a user object
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Mainly Used for Unit Teststing
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// User object is used for role checking
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public DealController(User currentUser, LuminousContext context, ProductController productctrl, UserController userctrl)
|
||||||
|
{
|
||||||
|
this.currentUser = currentUser;
|
||||||
|
this.context = context;
|
||||||
|
this.productctrl = productctrl;
|
||||||
|
this.userctrl = userctrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets All Deals
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires no special roles.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns a ICollection of all Deals.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Deal> GetAll()
|
public ICollection<Deal> GetAll()
|
||||||
{
|
{
|
||||||
return context.Deal.ToList();
|
return context.Deal.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches a deal by given Id.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns an object of the role with the given Id.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
|
public Deal Get(int id)
|
||||||
|
{
|
||||||
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
|
{
|
||||||
|
return context.Deal.Find(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Insufficient Roles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets deals between time periods.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns a collection of all the deal in the criteria.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Deal> GetByTime(DateTime startTime, DateTime endTime)
|
public ICollection<Deal> GetByTime(DateTime startTime, DateTime endTime)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
if (currentUser.RoleId > 1)
|
||||||
@@ -37,6 +107,17 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets deals made by certain user.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accepts user id for getting the user.
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns an Collection of all the deals in the criteria.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Deal> GetByUser(int id)
|
public ICollection<Deal> GetByUser(int id)
|
||||||
{
|
{
|
||||||
if (currentUser != null || currentUser.RoleId > 1)
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
@@ -57,6 +138,17 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets deals made by certain user.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accepts username for getting the user.
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns an Collection of all the deals in the criteria.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Deal> GetByUser(string username)
|
public ICollection<Deal> GetByUser(string username)
|
||||||
{
|
{
|
||||||
if (currentUser != null || currentUser.RoleId > 1)
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
@@ -82,7 +174,7 @@ namespace Business.Business.Sales
|
|||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||||
productCtrl.RemoveAmount(productId, Amount);
|
productctrl.RemoveAmount(productId, Amount);
|
||||||
context.Deal.Add(deal);
|
context.Deal.Add(deal);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -91,20 +183,15 @@ namespace Business.Business.Sales
|
|||||||
throw new ArgumentException("Amount cannot be negative");
|
throw new ArgumentException("Amount cannot be negative");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Deal Get(int id)
|
|
||||||
{
|
|
||||||
return context.Deal.Find(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(string productName, double Amount, DateTime time)
|
public void Add(string productName, double Amount, DateTime time)
|
||||||
{
|
{
|
||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
productCtrl = new ProductController(currentUser);
|
productctrl = new ProductController(currentUser);
|
||||||
var productId = productCtrl.Get(productName).Id;
|
var productId = productctrl.Get(productName).Id;
|
||||||
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
var deal = new Deal(currentUser.Id, productId, Amount, time);
|
||||||
productCtrl.RemoveAmount(productId, Amount);
|
productctrl.RemoveAmount(productId, Amount);
|
||||||
context.Deal.Add(deal);
|
context.Deal.Add(deal);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -121,7 +208,7 @@ namespace Business.Business.Sales
|
|||||||
var deal = Get(id);
|
var deal = Get(id);
|
||||||
if (deal != null)
|
if (deal != null)
|
||||||
{
|
{
|
||||||
productCtrl.AddAmount(deal.ProductId, deal.Amount);
|
productctrl.AddAmount(deal.ProductId, deal.Amount);
|
||||||
context.Deal.Remove(deal);
|
context.Deal.Remove(deal);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@@ -31,23 +31,25 @@ namespace Business.Business.Sales
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Custom context is mainly used for Unit Testing
|
/// Custom context is mainly used for Unit Testing
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// User object is used for role checking
|
/// User object is used for role checking
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public ProductController(LuminousContext context, User currenUser)
|
public ProductController(User currenUser, LuminousContext context)
|
||||||
{
|
{
|
||||||
this.currentUser = currenUser;
|
this.currentUser = currenUser;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets All Roles
|
/// Gets All Products
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Requires no special roles.
|
/// Requires no special roles.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// Returns a ICollection of all roles.
|
/// Returns a ICollection of all products.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Product> GetAll()
|
public ICollection<Product> GetAll()
|
||||||
@@ -56,7 +58,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the role by given Id.
|
/// Searches a product by given Id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Requires no special roles.
|
/// Requires no special roles.
|
||||||
@@ -79,7 +81,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the role by given name
|
/// Searches a product by given name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Requires no special roles.
|
/// Requires no special roles.
|
||||||
@@ -102,7 +104,7 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the role by a given substring
|
/// Searches a product by a given substring
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Requires no special roles.
|
/// Requires no special roles.
|
||||||
@@ -128,9 +130,10 @@ namespace Business.Business.Sales
|
|||||||
/// Adds an product in the database
|
/// Adds an product in the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// Requires Admin role.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// Accepts an item name and price.
|
/// Accepts an item name and price.
|
||||||
///
|
|
||||||
/// Requires no special roles
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void AddItem(string name, double price)
|
public void AddItem(string name, double price)
|
||||||
@@ -165,9 +168,10 @@ namespace Business.Business.Sales
|
|||||||
/// Updates the name of the given product
|
/// Updates the name of the given product
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// Requires Admin role.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// Accepts the id for getting the product.
|
/// Accepts the id for getting the product.
|
||||||
///
|
|
||||||
/// Requires Admin role
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void UpdateName(int id, string newName)
|
public void UpdateName(int id, string newName)
|
||||||
@@ -202,9 +206,10 @@ namespace Business.Business.Sales
|
|||||||
/// Updates the name of the given product
|
/// Updates the name of the given product
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// Requires Admin role.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// Accepts the current name for getting the product.
|
/// Accepts the current name for getting the product.
|
||||||
///
|
|
||||||
/// Requires Admin role
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void UpdateName(string oldName, string newName)
|
public void UpdateName(string oldName, string newName)
|
||||||
@@ -239,9 +244,10 @@ namespace Business.Business.Sales
|
|||||||
/// Updates the price of the given product
|
/// Updates the price of the given product
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// Requires Admin role.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// Accepts the id for getting the product.
|
/// Accepts the id for getting the product.
|
||||||
///
|
|
||||||
/// Requires Admin role
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void UpdatePrice(int id, double price)
|
public void UpdatePrice(int id, double price)
|
||||||
@@ -273,12 +279,13 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the price of the given product
|
/// Updates the price of the given product.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// Requires Admin role.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
/// Accepts the name for getting the product.
|
/// Accepts the name for getting the product.
|
||||||
///
|
|
||||||
/// Requires Admin role
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void UpdatePrice(string name, double price)
|
public void UpdatePrice(string name, double price)
|
||||||
@@ -309,6 +316,15 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds to the amount of a given product.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires no special roles.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accepts the product id for getting the product and amount to add
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public void AddAmount(int productId ,double Amount)
|
public void AddAmount(int productId ,double Amount)
|
||||||
{
|
{
|
||||||
@@ -330,6 +346,17 @@ namespace Business.Business.Sales
|
|||||||
throw new ArgumentException("Insufficient Role!");
|
throw new ArgumentException("Insufficient Role!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Subtracts to the amount of a given product.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires no special roles.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accepts the product id for getting the product and amount to substract
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public void RemoveAmount(int productId, double Amount)
|
public void RemoveAmount(int productId, double Amount)
|
||||||
{
|
{
|
||||||
if (currentUser.RoleId > 1)
|
if (currentUser.RoleId > 1)
|
||||||
@@ -352,12 +379,13 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the given product
|
/// Deletes the given product.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Accepts an product for getting the product
|
/// Requires Admin Role
|
||||||
///
|
/// </remarks>
|
||||||
/// Requires Admin role
|
/// <remarks>
|
||||||
|
/// Accepts an product for getting the product.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
|
|
||||||
@@ -386,10 +414,11 @@ namespace Business.Business.Sales
|
|||||||
/// Deletes the given product
|
/// Deletes the given product
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Accepts an name for getting the product
|
|
||||||
///
|
|
||||||
/// Requires Admin role
|
/// Requires Admin role
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// Accepts an name for getting the product
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public void Delete(string name)
|
public void Delete(string name)
|
||||||
{
|
{
|
||||||
|
@@ -11,24 +11,54 @@ namespace Business.Business.Sales
|
|||||||
{
|
{
|
||||||
public class StockController : ISalesController<Stock>
|
public class StockController : ISalesController<Stock>
|
||||||
{
|
{
|
||||||
private LuminousContext context = new LuminousContext();
|
private LuminousContext context;
|
||||||
private User currentUser;
|
private User currentUser;
|
||||||
private ProductController productCtrl;
|
private ProductController productctrl;
|
||||||
private UserController userctrl;
|
private UserController userctrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor that accepts a user object
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// User object is used for role checking
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public StockController(User currentUser)
|
public StockController(User currentUser)
|
||||||
{
|
{
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.productCtrl = new ProductController(currentUser);
|
this.context = new LuminousContext();
|
||||||
|
this.productctrl = new ProductController(currentUser);
|
||||||
this.userctrl = new UserController(currentUser);
|
this.userctrl = new UserController(currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StockController(User currentUser, ProductController productctrl, UserController userctrl)
|
/// <summary>
|
||||||
|
/// Constructor that accepts custom context, ProductController, UserController and a user object
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Mainly Used for Unit Teststing
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// User object is used for role checking
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public StockController(User currentUser, LuminousContext context ,ProductController productctrl, UserController userctrl)
|
||||||
{
|
{
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.productCtrl = new ProductController(currentUser);
|
this.context = context;
|
||||||
this.userctrl = new UserController(currentUser);
|
this.productctrl = productctrl;
|
||||||
|
this.userctrl = userctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets All Stocks
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires no special roles.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns a ICollection of all Deals.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Stock> GetAll()
|
public ICollection<Stock> GetAll()
|
||||||
{
|
{
|
||||||
if (currentUser != null || currentUser.RoleId > 1)
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
@@ -42,6 +72,16 @@ namespace Business.Business.Sales
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches a stocks session by given Id.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns an object of the role with the given Id.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public Stock Get(int id)
|
public Stock Get(int id)
|
||||||
{
|
{
|
||||||
if (currentUser != null || currentUser.RoleId > 1)
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
@@ -50,10 +90,20 @@ namespace Business.Business.Sales
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Cannot get stock!");
|
throw new ArgumentException("Insufficient Roles");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets stocks between time periods.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Requires Manager role or better.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns a collection of all the stocks in the criteria.
|
||||||
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Stock> GetByTime(DateTime startTime, DateTime endTime)
|
public ICollection<Stock> GetByTime(DateTime startTime, DateTime endTime)
|
||||||
{
|
{
|
||||||
if (currentUser != null || currentUser.RoleId > 1)
|
if (currentUser != null || currentUser.RoleId > 1)
|
||||||
@@ -113,7 +163,7 @@ namespace Business.Business.Sales
|
|||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||||
productCtrl.AddAmount(productId, Amount);
|
productctrl.AddAmount(productId, Amount);
|
||||||
context.Stock.Add(stock);
|
context.Stock.Add(stock);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -135,10 +185,10 @@ namespace Business.Business.Sales
|
|||||||
{
|
{
|
||||||
if (Amount > 0)
|
if (Amount > 0)
|
||||||
{
|
{
|
||||||
productCtrl = new ProductController(currentUser);
|
productctrl = new ProductController(currentUser);
|
||||||
var productId = productCtrl.Get(productName).Id;
|
var productId = productctrl.Get(productName).Id;
|
||||||
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
var stock = new Stock(currentUser.Id, productId, Amount, time);
|
||||||
productCtrl.AddAmount(productId, Amount);
|
productctrl.AddAmount(productId, Amount);
|
||||||
context.Stock.Add(stock);
|
context.Stock.Add(stock);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -162,7 +212,7 @@ namespace Business.Business.Sales
|
|||||||
var stock = Get(id);
|
var stock = Get(id);
|
||||||
if (stock != null)
|
if (stock != null)
|
||||||
{
|
{
|
||||||
productCtrl.RemoveAmount(stock.ProductId, stock.Amount);
|
productctrl.RemoveAmount(stock.ProductId, stock.Amount);
|
||||||
context.Stock.Remove(stock);
|
context.Stock.Remove(stock);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@@ -14,10 +14,10 @@ namespace Business.Business.UserManagment.Controllers
|
|||||||
private User currentUser;
|
private User currentUser;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Empty Constructor
|
/// Empty Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Used for Initialiation of the roles in the database
|
/// Used for Initialiation of the roles in the database.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public RoleController()
|
public RoleController()
|
||||||
@@ -31,10 +31,10 @@ namespace Business.Business.UserManagment.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor that accepts a user object
|
/// Constructor that accepts a user object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// User object is used for role checking
|
/// User object is used for role checking.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public RoleController(User currentUser)
|
public RoleController(User currentUser)
|
||||||
@@ -44,13 +44,15 @@ namespace Business.Business.UserManagment.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor that accepts custom context and a user object
|
/// Constructor that accepts custom context and a user object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Custom context is mainly used for Unit Testing
|
/// Custom context is mainly used for Unit Testing.
|
||||||
/// User object is used for role checking
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// User object is used for role checking.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public RoleController(User currentUser, LuminousContext context)
|
public RoleController(User currentUser, LuminousContext context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -58,13 +60,13 @@ namespace Business.Business.UserManagment.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the roles
|
/// Creates the roles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Requires no special roles. Not even an registered user.
|
/// Requires no special roles. Not even an registered user.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Almost every method of each class checks if the user has suffficient roles for the task
|
/// Almost every method of each class checks if the user has suffficient roles for the task.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public void CreateInitialRoles()
|
public void CreateInitialRoles()
|
||||||
@@ -83,7 +85,7 @@ namespace Business.Business.UserManagment.Controllers
|
|||||||
/// Requires Admin role.
|
/// Requires Admin role.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// Returns a ICollection of all roles
|
/// Returns a ICollection of all roles.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
||||||
public ICollection<Role> GetAll()
|
public ICollection<Role> GetAll()
|
||||||
|
@@ -39,21 +39,18 @@ namespace Business.Business.UserManagment
|
|||||||
this.rolectrl = new RoleController(currentUser);
|
this.rolectrl = new RoleController(currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor that accepts custom context and a user object
|
// <summary>
|
||||||
|
/// Constructor that accepts custom context, rolectrl and a user object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Custom context is mainly used for Unit Testing
|
/// Custom context is mainly used for Unit Testing
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks>
|
||||||
|
/// Custom context is mainly used for Unit Testing
|
||||||
/// User object is used for role checking
|
/// User object is used for role checking
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public UserController(User currentUser, LuminousContext context)
|
|
||||||
{
|
|
||||||
this.currentUser = currentUser;
|
|
||||||
this.context = context;
|
|
||||||
this.rolectrl = new RoleController(currentUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserController(User currentUser, LuminousContext context, RoleController rolectrl)
|
public UserController(User currentUser, LuminousContext context, RoleController rolectrl)
|
||||||
{
|
{
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
|
Reference in New Issue
Block a user