Пример #1
0
        public ActionResult Index(string dictionaryCode, string word)
        {
            Dictionary dictionary = DictionaryRepository.Get(dictionaryCode);

            if (dictionary == null)
            {
                return(HttpNotFound());
            }
            string indexValue = ArabicHelper.Substitute(word);
            IEnumerable <DictionaryEntry> entries = DictionaryEntryRepository.Get(
                dictionaryCode: dictionaryCode,
                word: indexValue);

            if (!entries.Any())
            {
                return(HttpNotFound());
            }

            var viewModel = new ViewModel(word, dictionary, entries);

            return(View("DictionaryEntry", viewModel));
        }
Пример #2
0
        public ActionResult Index(string rootLetterNames)
        {
            string root = ArabicHelper.LetterNamesToArabic(rootLetterNames);
            IEnumerable <VerseAnalysis> verses =
                VerseAnalysisRepository.GetForRoot(root)
                .OrderBy(x => x.ChapterNumber)
                .ThenBy(x => x.VerseNumber);
            var extracts = new List <VerseViewModel>();

            foreach (VerseAnalysis verseAnalysis in verses)
            {
                foreach (VerseAnalysisWord analysisWord in verseAnalysis.Words)
                {
                    IEnumerable <VerseAnalysisWordPart> wordParts =
                        analysisWord.WordParts.Where(x => x.Root == root);
                    foreach (VerseAnalysisWordPart wordPart in wordParts)
                    {
                        VerseViewModel extract =
                            CreateVerseViewModel(verseAnalysis, analysisWord, wordPart);
                        extracts.Add(extract);
                    }
                }
            }

            var romanNumerals = new List <string> {
                "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"
            };
            var wordFormsData = extracts
                                .GroupBy(x => new
            {
                Type = x.SelectedWordPart.Description,
                x.SelectedWordPart.Form
            })
                                .OrderBy(x => romanNumerals.IndexOf(x.Key.Form));

            var wordTypesData = wordFormsData
                                .GroupBy(x => x.Key.Type)
                                .OrderBy(x => x.Key);

            var wordTypesViewModel = wordTypesData
                                     .Select(t =>
                                             new WordTypeViewModel(
                                                 type: t.Key,
                                                 wordForms: t.Select(f =>
                                                                     new WordFormViewModel(
                                                                         form: f.Key.Form,
                                                                         extracts: f
                                                                         )
                                                                     )
                                                 )
                                             );

            IEnumerable <DictionaryEntry> dictionaryEntries =
                DictionaryEntryRepository.Get(root);
            IEnumerable <Dictionary> dictionaries =
                dictionaryEntries
                .Select(x => x.DictionaryCode)
                .Distinct()
                .Select(DictionaryRepository.Get)
                .OrderBy(x => x.Name);

            var viewModel = new ViewModel(
                arabicRoot: root,
                rootLetterNames: rootLetterNames,
                dictionaries: dictionaries,
                types: wordTypesViewModel);

            return(View("RootAnalysis", viewModel));
        }