public bool IsStockDuplicatedInBasket(StockWithBooksBasket stockWithBooksBasket) { if (StockWithBooks.Any(s => s.StockId == stockWithBooksBasket.StockId)) { return(true); } return(false); }
public bool IsBookEanDuplicatedInBasket(StockWithBooksBasket stockWithBooksBasket) { if (StockWithBooks.Any(s => s.Ean13 == stockWithBooksBasket.Ean13)) { return(true); } return(false); }
public void AddNewStock(StockWithBooksBasket stockWithBooksBasket) { if (stockWithBooksBasket is null) { throw new ArgumentException("Requested stock cannot be null"); } if (IsStockDuplicatedInBasket(stockWithBooksBasket)) { throw new ArgumentException("Trying to add duplicate stock for basket"); } StockWithBooks.Add(stockWithBooksBasket); }