public Task <bool> Handle(RegisterNewCardTypeCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } var transactionType = new CardType(message.Id, message.Name); if (_cardTypeRepository.GetByName(message.Name) != null) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "The card type name has already been taken.")); return(Task.FromResult(false)); } if (_cardTypeRepository.GetById(message.Id) != null) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "The card type id has already been taken.")); return(Task.FromResult(false)); } _cardTypeRepository.Add(transactionType); if (Commit()) { Bus.RaiseEvent(new CardTypeRegisteredEvent(transactionType.Id, transactionType.Name)); } return(Task.FromResult(true)); }
private bool IsValidCreditCard(PurchaseEntity entity, CardDto card) { if (card == null) { return(false); } var cardType = cardTypeRepository.GetById(card.CardTypeId); if (cardType == null) { return(false); } return(entity.CardType == cardType.Code && entity.CardExpireDate.ToString("MM") == card.ExpireDate.ToString("MM") && entity.CardExpireDate.ToString("yyyy") == card.ExpireDate.ToString("yyyy") && entity.CardCvv == card.Cvv); }
public CardTypeViewModel GetById(Guid id) { return(_mapper.Map <CardTypeViewModel>(_CardTypeRepository.GetById(id))); }