예제 #1
0
        public void Execute(string[] jsons)
        {
            IValidationResult[] results = _validataCards.Execute(jsons);
            if (jsons.Length != results.Length)
            {
                throw new InvalidValidationResultCountException();
            }

            if (results.Any(_ => !_.Valid))
            {
                PublishErrorMessage(results);
            }
            else
            {
                int           newVersionNumber = _incrementVersionNumber.Execute();
                List <string> cardIDs          = new List <string>();
                foreach (IValidationResult validationResult in results)
                {
                    cardIDs.Add(validationResult.ValidCardData.CardID);
                    validationResult.ValidCardData.VersionAdded = newVersionNumber;
                    if (_cardGateway.HasCard(validationResult.ValidCardData.CardID))
                    {
                        _cardGateway.UpdateCard(validationResult.ValidCardData);
                        RemoveFromOldPack(validationResult);
                    }
                    else
                    {
                        _cardGateway.AddCard(validationResult.ValidCardData);
                    }
                }
                _packGateway.SetCards(cardIDs.ToArray(), newVersionNumber);
            }
        }
예제 #2
0
        public void Execute(string cardID)
        {
            if (!_cardGateway.HasCard(cardID))
            {
                return;
            }

            ICard thisCard = _cardGateway.GetCard(cardID);

            thisCard.VersionRemoved = _incrementVersionNumber.Execute();
            _cardGateway.UpdateCard(thisCard);
        }
예제 #3
0
 private void UpdateCardWithNewPackNumber(IValidationResult validationResult)
 {
     _cardGateway.UpdateCard(validationResult.ValidCardData);
 }