public CardGroup GetGroup(int id)
        {
            _logger.Info($"[GroupFacade] The group of words with id = {id} was requestet ");
            var resultGroup = new CardGroup();

            var mainCard = new Card(_dictionaryRepository.GetById(id));

            if (mainCard == null)
            {
                _logger.Error($"[GroupFacade] Main card is null with groupId {id}");
                throw new ArgumentException();
            }
            var mainCardList = new List <Card> {
                mainCard
            };
            var additionald = _cardGroupRepository.GetAdditionalCards(mainCard.Id);

            for (var i = 0; i < additionald.Count; i++)
            {
                var temp = new Card(_dictionaryRepository.GetById(additionald[i]));
                mainCardList[i].AdditinalWord = temp.RussianValue;
                if (i == additionald.Count - 1)
                {
                    temp.AdditinalWord = mainCardList[i].RussianValue;
                }
                mainCardList.Add(temp);
            }
            resultGroup.Id    = mainCard.Id;
            resultGroup.Cards = mainCardList;
            return(resultGroup);
        }
Beispiel #2
0
        public WordDictionary GetById(int id)
        {
            _logger.Info($"[DictionaryService] The dictionary with id {id} was requested ");
            var requestResult = _repository.GetById(id);

            return(requestResult);
        }
Beispiel #3
0
        /// <summary>
        /// Checking answers
        /// </summary>
        /// <param name="dictionaryId"></param>
        /// <param name="chosenValue"></param>
        /// <returns></returns>
        public bool CheckQuiz(int dictionaryId, string chosenValue)
        {
            _logger.Info($"[QuizService] Checking of  dictionary with id {dictionaryId} and word {chosenValue} was requested ");
            var correctValue = _repository.GetById(dictionaryId);

            return(correctValue.EnglishValue.Equals(chosenValue) ||
                   correctValue.RussianValue.Equals(chosenValue));
        }