You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Maximum number of units that can be in-stock at any time (due to physicial/logistical constraints in warehouses)
34
+
publicintMaxStockThreshold{get;set;}
35
+
36
+
/// <summary>
37
+
/// True if item is on reorder
38
+
/// </summary>
39
+
publicboolOnReorder{get;set;}
40
+
41
+
publicCatalogItem(){}
42
+
43
+
44
+
/// <summary>
45
+
/// Decrements the quantity of a particular item in inventory and ensures the restockThreshold hasn't
46
+
/// been breached. If so, a RestockRequest is generated in CheckThreshold.
47
+
///
48
+
/// If there is sufficient stock of an item, then the integer returned at the end of this call should be the same as quantityDesired.
49
+
/// In the event that there is not sufficient stock available, the method will remove whatever stock is available and return that quantity to the client.
50
+
/// In this case, it is the responsibility of the client to determine if the amount that is returned is the same as quantityDesired.
51
+
/// It is invalid to pass in a negative number.
52
+
/// </summary>
53
+
/// <param name="quantityDesired"></param>
54
+
/// <returns>int: Returns the number actually removed from stock. </returns>
55
+
///
56
+
publicintRemoveStock(intquantityDesired)
57
+
{
58
+
if(AvailableStock==0)
59
+
{
60
+
thrownewCatalogDomainException($"Empty stock, product item {Name} is sold out");
61
+
}
62
+
63
+
if(quantityDesired<=0)
64
+
{
65
+
thrownewCatalogDomainException($"Item units desired should be greater than cero");
0 commit comments