public RevisionSessionsCommandsHandler(IUnitOfWork unitOfWork, IDomainEventPublisher eventPublisher,
                                        ICardAnswerCheckService cardAnswerCheckService, IRevisionSessionsRepository revisionSessionsRepository)
 {
     _unitOfWork                 = unitOfWork;
     _eventPublisher             = eventPublisher;
     _cardAnswerCheckService     = cardAnswerCheckService;
     _revisionSessionsRepository = revisionSessionsRepository;
 }
Example #2
0
        public void CardAnswered(Guid cardId, SessionCardAnswerType answerType, string answer,
                                 ICardAnswerCheckService answerCheckService)
        {
            var card = SessionCards.FirstOrDefault(sc => sc.CardId == cardId);

            if (card == null)
            {
                throw new InvalidOperationException("Couldn't find a card with the id in the revision session");
            }

            CardAnswered(cardId, answerCheckService.CheckAnswer(
                             answerType == SessionCardAnswerType.NativeLanguage ? card.NativeLanguageWord : card.TargetLanguageWord,
                             answer)
                ? SessionCardStatus.AnsweredCorrectly
                : SessionCardStatus.AnsweredWrong);
        }