public int GetCount(ICardCountKey key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (CardCountKeys.Standard.Equals(key)) { return(Number); } if (CardCountKeys.Foil.Equals(key)) { return(FoilNumber); } if (CardCountKeys.AltArt.Equals(key)) { return(AltArtNumber); } if (CardCountKeys.FoilAltArt.Equals(key)) { return(FoilAltArtNumber); } throw new ArgumentException("Unmanaged type of key", nameof(key)); }
public bool Equals(ICardCountKey other) { if (other == null) { return(false); } return(IsFoil == other.IsFoil && IsAltArt == other.IsAltArt); }
public int GetCount(ICardCountKey key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (!_counts.TryGetValue(key, out int value)) { return(0); } return(value); }
private void AuditAddCard(int idCollection, int idGatherer, int idLanguage, ICardCountKey cardCountKey, int countToAdd) { if (idCollection <= 0 || countToAdd == 0 || idGatherer == 0 || idLanguage < 0 || cardCountKey == null) { return; } InsertNewAudit(new Audit { IdCollection = idCollection, Quantity = countToAdd, IdGatherer = idGatherer, IsFoil = cardCountKey.IsFoil, IsAltArt = cardCountKey.IsAltArt, IdLanguage = idLanguage }); }
public void ChangeCardEditionFoilAltArtLanguage(ICardCollection collection, ICard card, int countToChange, IEdition editionSource, ICardCountKey cardCountKeySource, ILanguage languageSource, IEdition editionDestination, ICardCountKey cardCountKeyDestination, ILanguage languageDestination) { if (countToChange <= 0) { return; } using (new WriterLock(_lock)) { if (languageSource == null || languageDestination == null || cardCountKeySource == null || cardCountKeyDestination == null) { return; } int idGathererSource = GetIdGatherer(card, editionSource); int idGathererDestination = GetIdGatherer(card, editionDestination); ICardInCollectionCount cardInCollectionCount = GetCardCollection(collection, idGathererSource, languageSource.Id); if (cardInCollectionCount == null || idGathererDestination == 0) { return; } if (cardInCollectionCount.GetCount(cardCountKeySource) < countToChange) { return; } CardCount cardCountSource = new CardCount { { cardCountKeySource, -countToChange } }; CardCount cardCountDestination = new CardCount { { cardCountKeyDestination, countToChange } }; InsertOrUpdateCardInCollection(collection.Id, idGathererSource, languageSource.Id, cardCountSource); InsertOrUpdateCardInCollection(collection.Id, idGathererDestination, languageDestination.Id, cardCountDestination); } }
public void Add(ICardCountKey key, int count) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (count == 0) { return; } if (!_counts.TryGetValue(key, out int value)) { value = 0; } value += count; _counts[key] = value; }
private void MoveCardToOtherCollection(ICardCollection collection, int idGatherer, int idLanguage, int countToMove, ICardCountKey cardCountKey, ICardCollection collectionDestination) { if (countToMove <= 0 || cardCountKey == null) { return; } using (new WriterLock(_lock)) { ICardInCollectionCount cardInCollectionCount = GetCardCollection(collection, idGatherer, idLanguage); if (cardInCollectionCount == null) { return; } if (cardInCollectionCount.GetCount(cardCountKey) < countToMove) { return; } CardCount cardCountSource = new CardCount { { cardCountKey, -countToMove } }; CardCount cardCountDestination = new CardCount { { cardCountKey, countToMove } }; InsertOrUpdateCardInCollection(collection.Id, idGatherer, idLanguage, cardCountSource); InsertOrUpdateCardInCollection(collectionDestination.Id, idGatherer, idLanguage, cardCountDestination); } }
public int GetCount(ICardCountKey key) { return(_cardCount.GetCount(key)); }
internal void Add(ICardCountKey key, int number) { _cardCount.Add(key, number); }
public int GetCount(ICardCountKey key) { return(-1); }