public void AddItem(Book book, int quantity) { CartLine line = lineCollection.Where(b => b.Book.Id == book.Id).FirstOrDefault(); if(line == null) { lineCollection.Add(new CartLine { Book = book, Quantity = quantity }); } else { line.Quantity += quantity; } }
public void RemoveLine(Book book) { lineCollection.RemoveAll(l => l.Book.Id == book.Id); }