Пример #1
0
        public bool IsStockDuplicatedInBasket(StockWithBooksBasket stockWithBooksBasket)
        {
            if (StockWithBooks.Any(s => s.StockId == stockWithBooksBasket.StockId))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        public bool IsBookEanDuplicatedInBasket(StockWithBooksBasket stockWithBooksBasket)
        {
            if (StockWithBooks.Any(s => s.Ean13 == stockWithBooksBasket.Ean13))
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
 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);
 }