public virtual CardInCardList RemoveCard(Card card, int quantity = 1) { var cardInList = CardInCardLists.First(c => c.CardId == card.Id); if (cardInList.Quantity <= quantity) { CardInCardLists.Remove(cardInList); } else { cardInList.Quantity -= quantity; } return cardInList; }
public virtual CardInCardList AddCard(Card card, int quantity = 1, int number = 1) { var cardInList = CardInCardLists.FirstOrDefault(c => c.CardId == card.Id); if (cardInList == null) { cardInList = new CardInCardList {Card = card, CardList = this, Number = number, Quantity = quantity}; CardInCardLists.Add(cardInList); } else { cardInList.Quantity += quantity; } return cardInList; }