public bool AddProduct(ProductQuantity productQuantity, int userId) { ProductQuantity selectedProduct = _productQuantities .FirstOrDefault(p => p.ProductId == productQuantity.ProductId); selectedProduct.Quantity += productQuantity.Quantity; UserProductAction userProductAction = new UserProductAction() { ProductId = productQuantity.ProductId, Quantity = productQuantity.Quantity, UserId = userId, ActionType = UserProductActionType.Add }; return(true); }
public bool RemoveProduct(ProductQuantity productQuantity, int userId) { ProductQuantity selectedProduct = _productQuantities .FirstOrDefault(p => p.ProductId == productQuantity.ProductId); // Check if fridge has product if (selectedProduct.Quantity < productQuantity.Quantity) { return(false); } selectedProduct.Quantity -= productQuantity.Quantity; UserProductAction userProductAction = new UserProductAction() { ProductId = productQuantity.ProductId, Quantity = productQuantity.Quantity, UserId = userId, ActionType = UserProductActionType.Remove }; return(true); }