Example #1
0
        public ActionResult Download(UserLanguages userLanguages, DocumentType type)
        {
            if (IsInvalid(userLanguages))
            {
                return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME));
            }

            List <SourceWithTranslation> words = GetWords(userLanguages);

            string header = WebSettingsConfig.Instance.GetTemplateText(SectionId.PopularWord, PageId.Index,
                                                                       TemplateId.Header);

            var downloader = new PopularWordsDownloader(WebSettingsConfig.Instance.DomainWithProtocol,
                                                        CommonConstants.GetFontPath(Server))
            {
                Header = header
            };
            DocumentationGenerator documentGenerator = downloader.Download(type, header, words);

            return(File(documentGenerator.Generate(), documentGenerator.ContentType, documentGenerator.FileName));
        }
Example #2
0
        private DocumentationGenerator GetGenerator(AllMaterialsQuery allMaterialsQuery,
                                                    SectionId sectionId,
                                                    long id,
                                                    string title)
        {
            DocumentationGenerator result;

            switch (sectionId)
            {
            case SectionId.GroupByWords:
                var groupWordsDownloader = new GroupDataDownloader(_domain, _fontPath)
                {
                    Header      = string.Format("Слова на тему «{0}»", title),
                    TableHeader = "Слово"
                };

                List <SourceWithTranslation> words = allMaterialsQuery.GetWordsByGroup(id);
                result = groupWordsDownloader.Download(DOCUMENT_TYPE, title, words);
                break;

            case SectionId.GroupByPhrases:
                var groupDataDownloader = new GroupDataDownloader(_domain, _fontPath)
                {
                    Header      = string.Format("Фразы на тему «{0}»", title),
                    TableHeader = "Фраза"
                };

                List <SourceWithTranslation> sentences = allMaterialsQuery.GetSentencesByGroup(id);
                result = groupDataDownloader.Download(DOCUMENT_TYPE, title, sentences);
                break;

            case SectionId.VisualDictionary:
                var visualDictionaryDownloader = new VisualDictionaryDownloader(_domain, _fontPath);

                RepresentationForUser representationForUser = allMaterialsQuery.GetVisualDictionary(title);
                result = visualDictionaryDownloader.Download(DOCUMENT_TYPE, title, representationForUser);
                break;

            case SectionId.FillDifference:
                var comparisonDownloader = new ComparisonDownloader(_domain, _fontPath);

                ComparisonForUser comparisonForUser = allMaterialsQuery.GetComparison(title);
                result = comparisonDownloader.Download(DOCUMENT_TYPE, title, comparisonForUser);
                break;

            case SectionId.Video:
                var videoTextDownloader = new VideoTextDownloader(_domain, _fontPath);

                VideoForUser videoForUser = allMaterialsQuery.GetVideo(title);
                result = videoTextDownloader.Download(DOCUMENT_TYPE, title, videoForUser);
                break;

            case SectionId.PopularWord:
                var popularWordsDownloader = new PopularWordsDownloader(_domain, _fontPath)
                {
                    Header = "Минилекс слов Гуннемарка"
                };

                List <SourceWithTranslation> popularWords = allMaterialsQuery.GetPopularWords();
                result = popularWordsDownloader.Download(DOCUMENT_TYPE, title, popularWords);
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }