public void PreconstructedDeckToCollection(IPreconstructedDeck preconstructedDeck, ICardCollection collection, ILanguage language) { using (new WriterLock(_lock)) { if (preconstructedDeck == null || collection == null || language == null) { return; } ICollection <IPreconstructedDeckCardEdition> deckComposition = GetPreconstructedDeckCards(preconstructedDeck); if (deckComposition == null || deckComposition.Count == 0) { return; } int idLanguage = language.Id; using (BatchMode()) { foreach (IPreconstructedDeckCardEdition card in deckComposition) { CardCount cardCount = new CardCount { { CardCountKeys.Standard, card.Number } }; InsertOrUpdateCardInCollection(collection.Id, card.IdGatherer, idLanguage, cardCount); } } } }
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 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 DeleteAllCardInCollection(string name) { using (new WriterLock(_lock)) { ICardCollection cardCollection = GetCollection(name); if (cardCollection == null) { return; } ICollection <ICardInCollectionCount> collection = GetCardCollection(cardCollection); if (collection == null || collection.Count == 0) { return; } using (BatchMode()) { using (IDbConnection cnx = _databaseConnection.GetMagicConnection()) { Mapper <CardInCollectionCount> .DeleteMulti(cnx, collection.Cast <CardInCollectionCount>()); } foreach (ICardInCollectionCount cardInCollectionCount in collection) { ICardCount cardCount = new CardCount(); foreach (KeyValuePair <ICardCountKey, int> kv in cardInCollectionCount.GetCardCount()) { cardCount.Add(kv.Key, -kv.Value); } AuditAddCard(cardInCollectionCount.IdCollection, cardInCollectionCount.IdGatherer, cardInCollectionCount.IdLanguage, cardCount); RemoveFromReferential(cardInCollectionCount); } } } }