protected JsonResult SetMarkAndGetModel(long userId, UserLanguages userLanguages, long groupId, KnowledgeMark mark, TrainerItem item) { var itemDataType = (KnowledgeDataType)(item != null ? item.DataType : int.MinValue); if (IdValidator.IsInvalid(userId) || UserLanguages.IsInvalid(userLanguages) || EnumValidator.IsInvalid(mark) || item == null || IdValidator.IsInvalid(item.DataId) || EnumValidator.IsInvalid(itemDataType) || IdValidator.IsInvalid(groupId)) { //TODO: писать сообщение return(JsonResultHelper.Error()); } IUserRepetitionIntervalQuery userRepetitionIntervalQuery = CreateUserRepetitionIntervalQuery(userId, groupId); var repetitionInterval = new UserRepetitionIntervalItem { DataId = item.DataId, DataType = itemDataType, SourceType = KnowledgeSourceType }; var trainerHelper = new TrainerHelper(userRepetitionIntervalQuery, userLanguages); return(trainerHelper.SetMark(Request, mark, repetitionInterval)); }
public ActionResult GetFile(UserLanguages userLanguages, GroupForUser group, DocumentType docType, string fileName) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages) || group == null) { return(GetRedirectToGroups()); } GroupModel model = GetModel(userLanguages, group); if (model.IsInvalid()) { return(GetRedirectToGroups()); } string header = WebSettingsConfig.Instance.GetTemplateText(SectionId, PageId.Detail, TemplateId.Header, group.Name); header = HttpUtility.HtmlDecode(header); var downloader = new GroupDataDownloader(WebSettingsConfig.Instance.DomainWithProtocol, CommonConstants.GetFontPath(Server)) { Header = header, TableHeader = TableHeader }; var documentGenerator = downloader.Download(docType, fileName, model.ElemsWithTranslations); Stream stream = documentGenerator.Generate(); return(File(stream, documentGenerator.ContentType, documentGenerator.FileName)); }
public ActionResult Index(long userId, UserLanguages userLanguages) { const string EMPTY_WALL_VIEW = "EmptyWall"; if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId.MyKnowledge)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (IdValidator.IsInvalid(userId) || UserLanguages.IsInvalid(userLanguages)) { return(View(EMPTY_WALL_VIEW)); } IUserKnowledgeQuery userKnowledgeQuery = CreateUserKnowledgeQuery(userId); List <UserKnowledgeItem> items = GetData(userKnowledgeQuery, userLanguages, long.MaxValue); if (items == null || EnumerableValidator.IsEmpty(items)) { return(View(EMPTY_WALL_VIEW)); } //TODO: если будет тормозить - получать ajax'ом данные через action GetStatistic UserKnowledgeStatistic statistic = userKnowledgeQuery.GetStatistic(); return(View("Index", new KnowledgeWallModel(userLanguages, items) { Statistic = statistic })); }
/// <summary> /// Возвращает перевод для слова /// </summary> /// <param name="sourceLanguage">язык, на котором введено слово</param> /// <param name="destinationLanguage">язык, на который нужно перевести слово</param> /// <param name="word">слово, которое нужно перевести</param> /// <returns>переведенное слово</returns> public ActionResult Translation(string sourceLanguage, string destinationLanguage, string word) { const string ACTION_NAME = "Index"; if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } var languages = new LanguagesQuery(WebSettingsConfig.Instance.DefaultLanguageFrom, WebSettingsConfig.Instance.DefaultLanguageTo); LanguageShortName source = LanguagesQuery.ParseShortName(sourceLanguage); LanguageShortName destination = LanguagesQuery.ParseShortName(destinationLanguage); UserLanguages userLanguages = languages.GetLanguagesByShortNames(source, destination); if (UserLanguages.IsInvalid(userLanguages) || string.IsNullOrEmpty(word)) { return(RedirectToAction(ACTION_NAME, ControllerName)); } List <PronunciationForUser> translationWords = GetTranslationsByQuery(userLanguages, word); return(View(ACTION_NAME, new TranslatorModel(userLanguages, word, translationWords))); }
protected ActionResult GetIndex(long userId, UserLanguages userLanguages, long groupId, Action <TrainerModel> modelSetter) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (IdValidator.IsInvalid(userId) || UserLanguages.IsInvalid(userLanguages) || IdValidator.IsInvalid(groupId)) { return(RedirectToParentPage()); } IUserRepetitionIntervalQuery userRepetitionIntervalQuery = CreateUserRepetitionIntervalQuery(userId, groupId); var trainerHelper = new TrainerHelper(userRepetitionIntervalQuery, userLanguages); TrainerModel model = trainerHelper.GetTrainerModel(Request); modelSetter(model); if (EnumerableValidator.IsNullOrEmpty(model.Items)) { return(RedirectToParentPage()); } ViewData[OurHtmlHelper.ViewDataFlags.SKIP_POPUP_PANEL] = true; return(View("../Trainer/Index", model)); }
public ActionResult Index(UserLanguages userLanguages, string group) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId.VisualDictionary)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME)); } RepresentationForUser representationForUser = GetRepresentationForUser(userLanguages, group); if (representationForUser == null) { return(RedirectToActionPermanent("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME)); } long languageId = WebSettingsConfig.Instance.GetLanguageFromId(); var crossReferencesQuery = new CrossReferencesQuery(languageId); List <CrossReference> crossReferences = crossReferencesQuery.GetReferences(representationForUser.Id, CrossReferenceType. VisualDictionary); var model = new VisualDictionaryModel(userLanguages, representationForUser); model.CrossReferencesModel = new CrossReferencesModel(representationForUser.Title, CrossReferenceType.VisualDictionary, crossReferences); return(View(model)); }
public ActionResult Translation(long userId, long?sourceId, long?translationId) { if (WebSettingsConfig.Instance.IsSectionForbidden(_sectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (!sourceId.HasValue || !translationId.HasValue) { return(RedirectToAction(_viewName)); } List <SourceWithTranslation> sourceWithTranslations = _query.GetExact(userId, sourceId.Value, translationId.Value); if (sourceWithTranslations == null || sourceWithTranslations.Count == 0) { return(RedirectToAction(_viewName)); } var languages = new LanguagesQuery(WebSettingsConfig.Instance.DefaultLanguageFrom, WebSettingsConfig.Instance.DefaultLanguageTo); SourceWithTranslation currentSentence = sourceWithTranslations.Single(e => e.IsCurrent); UserLanguages userLanguages = languages.GetLanguages(new List <long> { currentSentence.Source.LanguageId, currentSentence.Translation.LanguageId }); if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction(_viewName)); } return(View(_viewName, new ShuffleModel(userLanguages, sourceWithTranslations))); }
public ActionResult ShowAll(UserLanguages userLanguages, GroupForUser group, CrossReferenceType crossReferenceType) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages) || group == null) { return(GetRedirectToGroups()); } GroupModel model = GetModel(userLanguages, group); if (model.IsInvalid()) { return(GetRedirectToGroups()); } long languageId = WebSettingsConfig.Instance.GetLanguageFromId(); var crossReferencesQuery = new CrossReferencesQuery(languageId); List <CrossReference> crossReferences = crossReferencesQuery.GetReferences(group.Id, crossReferenceType); model.CrossReferencesModel = new CrossReferencesModel(group.Name, crossReferenceType, crossReferences); return(View("All", model)); }
public JsonResult MarkAsShowed(long userId, long id) { if (UserLanguages.IsInvalid(_userLanguages)) { return(JsonResultHelper.Error()); } return(_shuffleController.MarkAsShowed(userId, id, _userLanguages)); }
public ActionResult Index(long userId) { if (UserLanguages.IsInvalid(_userLanguages)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } return(_shuffleController.Index(userId, _userLanguages)); }
public ActionResult ShowSpecialItem(UserLanguages userLanguages, GroupForUser group, string elem1, string elem2) { if (UserLanguages.IsInvalid(userLanguages) || group == null || string.IsNullOrWhiteSpace(elem1) || string.IsNullOrWhiteSpace(elem2)) { return(GetRedirectToGroups()); } return(ShowSpecial(userLanguages, group, model => FoundTranslation(elem1, elem2, model))); }
public JsonResult GetTranslations(UserLanguages userLanguages, string query) { if (UserLanguages.IsInvalid(userLanguages)) { return(JsonResultHelper.Error()); } List <PronunciationForUser> result = GetTranslationsByQuery(userLanguages, query); return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult MarkAsShowed(long userId, long id, UserLanguages userLanguages) { if (IsInvalid(id, userId) || UserLanguages.IsInvalid(userLanguages)) { return(JsonResultHelper.Error()); } bool result = _query.MarkAsShowed(userId, userLanguages, id); return(JsonResultHelper.Success(result)); }
public JsonResult GetNextPortion(long userId, long id) { if (UserLanguages.IsInvalid(_userLanguages)) { return(JsonResultHelper.Error()); } return(_shuffleController.GetPortion(userId, id, uId => _query.GetNextPortion(uId, id, _userLanguages))); }
public ActionResult ShowSpecialItem(UserLanguages userLanguages, GroupForUser group, long elem1, long elem2) { if (UserLanguages.IsInvalid(userLanguages) || group == null || IdValidator.IsInvalid(elem1) || IdValidator.IsInvalid(elem2)) { return(GetRedirectToGroups()); } return(ShowSpecial(userLanguages, group, model => FoundTranslation(elem1, elem2, model))); }
public ActionResult Index(UserLanguages userLanguages) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } return(View(new TranslatorModel(userLanguages))); }
private bool IsInvalid(UserLanguages userLanguages) { if (UserLanguages.IsInvalid(userLanguages)) { return(true); } if (!IsShortNameValid(userLanguages.From)) { return(true); } return(!IsShortNameValid(userLanguages.To)); }
public List <SourceWithTranslation> GetPrevPortion(long userId, long id, UserLanguages userLanguages, int countSentences = PORTION_SIZE) { if (UserLanguages.IsInvalid(userLanguages)) { return(new List <SourceWithTranslation>(0)); } long sourceLanguageId = userLanguages.From.Id; long translationLanguageId = userLanguages.To.Id; return(GetPrevById(userId, id, sourceLanguageId, translationLanguageId, countSentences)); }
public List <SourceWithTranslation> GetNextPortion(long userId, long id, UserLanguages userLanguages, int count = PORTION_SIZE) { if (UserLanguages.IsInvalid(userLanguages)) { return(new List <SourceWithTranslation>(0)); } long sourceLanguageId = userLanguages.From.Id; long translationLanguageId = userLanguages.To.Id; List <SourceWithTranslation> result = GetNextById(userId, id, sourceLanguageId, translationLanguageId, count); bool needCreate = NeedCreate(result); if (!needCreate) { return(result); } //попробовать добавить новые предложения и вернуть большее кол-во предложений bool isInserted = InsertShuffle(userId, sourceLanguageId, translationLanguageId, count); if (!isInserted) { return(result); } //result = GetNextById(userUnique, id, sourceLanguageId, translationLanguageId, count); SourceWithTranslation lastSentence = result.LastOrDefault(); if (lastSentence == null) { //нет ни одного предложения - даже после вставки:( LoggerWrapper.LogTo(LoggerName.Default).InfoFormat( "BaseRandomQuery.GetNextPortion для пользователя {0} нет ни одного предложения даже после вставки. Может все просмотрел?", userId); return(result); } //получаем энтити - которые вставили List <SourceWithTranslation> nextPortion = GetNextById(userId, lastSentence.Id, sourceLanguageId, translationLanguageId, count); result.AddRange(nextPortion); return(result); }
public ActionResult Index(long userId, UserLanguages userLanguages) { if (WebSettingsConfig.Instance.IsSectionForbidden(_sectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } List <SourceWithTranslation> sentencesWithTranslations = IdValidator.IsValid(userId) ? _query.GetRandom(userId, userLanguages) : null; return(View(_viewName, new ShuffleModel(userLanguages, sentencesWithTranslations))); }
public ActionResult Download(UserLanguages userLanguages, string group, DocumentType type) { if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER)); } ComparisonForUser comparisonForUser = GetComparisonForUser(userLanguages, group); if (comparisonForUser == null) { return(RedirectToActionPermanent("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER)); } var downloader = new ComparisonDownloader(WebSettingsConfig.Instance.DomainWithProtocol, CommonConstants.GetFontPath(Server)); var documentGenerator = downloader.Download(type, comparisonForUser.Title, comparisonForUser); return(File(documentGenerator.Generate(), documentGenerator.ContentType, documentGenerator.FileName)); }
public ActionResult GetTrainer(UserLanguages userLanguages, GroupForUser group) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages) || group == null) { return(GetRedirectToGroups()); } GroupModel model = GetModel(userLanguages, group); if (model.IsInvalid()) { return(GetRedirectToGroups()); } model.SetCurrent(model.ElemsWithTranslations[0]); return(View("Index", model)); }
public ActionResult Index(UserLanguages userLanguages, string group) { if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId.FillDifference)) { return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME)); } if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER)); } ComparisonForUser comparisonForUser = GetComparisonForUser(userLanguages, group); if (comparisonForUser == null) { return(RedirectToActionPermanent("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER)); } return(View(comparisonForUser)); }
public ActionResult Download(UserLanguages userLanguages, string group, DocumentType type) { if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME)); } RepresentationForUser representationForUser = GetRepresentationForUser(userLanguages, group); if (representationForUser == null) { return(RedirectToActionPermanent("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME)); } var downloader = new VisualDictionaryDownloader(WebSettingsConfig.Instance.DomainWithProtocol, CommonConstants.GetFontPath(Server)); string fileName = string.Format("Визуальный словарь на тему {0}", representationForUser.Title.ToLowerInvariant()); DocumentationGenerator documentGenerator = downloader.Download(type, fileName, representationForUser); return(File(documentGenerator.Generate(), documentGenerator.ContentType, documentGenerator.FileName)); }
public JsonResult Load(long userId, UserLanguages userLanguages, long prevId) { if (IdValidator.IsInvalid(userId) || UserLanguages.IsInvalid(userLanguages) || IdValidator.IsInvalid(prevId)) { return(JsonResultHelper.Error(INVALID_DATA)); } IUserKnowledgeQuery userKnowledgeQuery = CreateUserKnowledgeQuery(userId); List <UserKnowledgeItem> items = GetData(userKnowledgeQuery, userLanguages, prevId); var htmlItems = new List <string>(); foreach (UserKnowledgeItem userKnowledgeItem in items ?? new List <UserKnowledgeItem>(0)) { string item = OurHtmlHelper.RenderRazorViewToString(ControllerContext, "PartialWallItem", userKnowledgeItem); htmlItems.Add(item); } return (JsonResultHelper.GetUnlimitedJsonResult( new { sourceLanguageId = userLanguages.From.Id, items = htmlItems })); }
public JsonResult Search(UserLanguages userLanguages, string query) { if (UserLanguages.IsInvalid(userLanguages)) { return(JsonResultHelper.Error()); } WordsByPattern result; if (!string.IsNullOrEmpty(query)) { var wordsQuery = new WordsQuery(); result = wordsQuery.GetLikeWords(userLanguages, query, WordType); if (EnumerableValidator.IsEmpty(result.Words)) { //попробовать перевести символы из латинских в русские, из русских в латинские result = GetKeyboardLayoutResult(userLanguages, query, wordsQuery); } } else { result = new WordsByPattern(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
private static bool IsInvalid(UserLanguages userLanguages) { return(UserLanguages.IsInvalid(userLanguages) || WebSettingsConfig.Instance.IsSectionForbidden(SectionId.PopularWord)); }
private static bool IsInvalid(long userId, UserLanguages userLanguages) { return(IdValidator.IsInvalid(userId) || UserLanguages.IsInvalid(userLanguages)); }
public ActionResult Index(UserLanguages userLanguages) { const int COUNT = 5; if (UserLanguages.IsInvalid(userLanguages)) { return(RedirectToAction("Unknown", "Errors")); } var model = new MainModel(); long languageId = WebSettingsConfig.Instance.GetLanguageFromId(); //слова по темам AddSectionIfNeed(SectionId.GroupByWords, model, () => { IGroupsQuery groupsQuery = new GroupsQuery(languageId); List <GroupForUser> groups = groupsQuery.GetVisibleGroups(GroupType.ByWord, COUNT); return(new DescriptionSection { Title = new DescriptionTitle { Title = "Слова по темам", Url = Url.Action("Index", RouteConfig.GROUPS_BY_WORDS_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти ко всем темам" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.GroupByWordsDescription), MostPopularTitle = "5 наиболее популярных тем:", Items = ConvertToItems(groups, e => e.Name), TitleItemGetter = item => WebSettingsConfig.Instance.GetTemplateText(SectionId.GroupByWords, PageId.Index, TemplateId.ItemTipOnMainPage, item.Title), UrlItemGetter = item => @Url.Action("Index", RouteConfig.GROUP_WORD_CONTROLLER, new { group = item.Title + "/" }, Request.Url.Scheme), UrlImageItemGetter = item => Url.Action("GetImageByName", RouteConfig.GROUP_WORD_CONTROLLER, new { group = item.Title }, Request.Url.Scheme), //Btn = BtnModel.CreateBuyAllMaterials(Url, "btn btn-danger btn-xs buy-btn-main") }); }); //почувствуй разницу AddSectionIfNeed(SectionId.FillDifference, model, () => { IComparisonsQuery comparisonsQuery = new ComparisonsQuery(languageId); List <ComparisonForUser> comparisons = comparisonsQuery.GetVisibleWithoutRules(COUNT); return(new DescriptionSection { Title = new DescriptionTitle { Title = "Почувствуй разницу", Url = Url.Action("Index", RouteConfig.GROUPS_BY_COMPARISONS_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти ко всем правилам употребления" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.FillDifferenceDescription), MostPopularTitle = "5 наиболее популярных тем сравнения:", Items = ConvertToItems(comparisons, e => e.Title), TitleItemGetter = item => WebSettingsConfig.Instance.GetTemplateText(SectionId.FillDifference, PageId.Index, TemplateId.ItemTipOnMainPage, item.Title), UrlItemGetter = item => Url.Action("Index", RouteConfig.COMPARISON_CONTROLLER, new { group = item.Title + "/" }, Request.Url.Scheme) }); }); //минилекс слов AddSectionIfNeed(SectionId.PopularWord, model, () => { return(new DescriptionSection { Title = new DescriptionTitle { Title = "Минилекс слов", Url = Url.Action("Index", RouteConfig.POPULAR_WORDS_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к минилексу слов Гуннемарка" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.PopularWordDescription) }); }); //визуальные словари AddSectionIfNeed(SectionId.VisualDictionary, model, () => { IRepresentationsQuery representationsQuery = new RepresentationsQuery(languageId); List <RepresentationForUser> visibleDictionaries = representationsQuery.GetVisibleWithoutAreas(COUNT); return(new DescriptionSection { Title = new DescriptionTitle { Title = "Визуальные словари", Url = Url.Action("Index", RouteConfig.VISUAL_DICTIONARIES_CONTROLLER_NAME, null, Request.Url.Scheme), Description = "Перейти ко всем визуальным словарям" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.VisualDictionaryDescription), MostPopularTitle = "5 наиболее популярных визуальных словарей:", Items = ConvertToItems(visibleDictionaries, e => e.Title), TitleItemGetter = item => WebSettingsConfig.Instance.GetTemplateText(SectionId.VisualDictionary, PageId.Index, TemplateId.ItemTipOnMainPage, item.Title), UrlItemGetter = item => Url.Action("Index", RouteConfig.VISUAL_DICTIONARY_CONTROLLER, new { group = item.Title + "/" }, Request.Url.Scheme), UrlImageItemGetter = item => Url.Action("GetImageByName", RouteConfig.VISUAL_DICTIONARY_CONTROLLER, new { group = item.Title }, Request.Url.Scheme), //Btn = BtnModel.CreateBuyVisualDictionaries(Url, "btn btn-danger btn-xs buy-btn-main") }); }); AddSectionIfNeed(SectionId.GroupByPhrases, model, () => { //фразы по темам IGroupsQuery groupsQuery = new GroupsQuery(languageId); List <GroupForUser> groups = groupsQuery.GetVisibleGroups(GroupType.BySentence, COUNT); return(new DescriptionSection { Title = new DescriptionTitle { Title = "Фразы по темам", Url = Url.Action("Index", RouteConfig.GROUPS_BY_SENTENCES_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти ко всем темам" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.GroupByPhrasesDescription), MostPopularTitle = "5 наиболее популярных тем:", Items = ConvertToItems(groups, e => e.Name), TitleItemGetter = item => WebSettingsConfig.Instance.GetTemplateText(SectionId.GroupByPhrases, PageId.Index, TemplateId.ItemTipOnMainPage, item.Title), UrlItemGetter = item => @Url.Action("Index", RouteConfig.GROUP_SENTENCE_CONTROLLER, new { group = item.Title + "/" }, Request.Url.Scheme), UrlImageItemGetter = item => Url.Action("GetImageByName", RouteConfig.GROUP_SENTENCE_CONTROLLER, new { group = item.Title }, Request.Url.Scheme), }); }); //стена знания AddSectionIfNeed(SectionId.MyKnowledge, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Стена знаний", Url = Url.Action("Index", RouteConfig.USER_KNOWLEDGE_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к стене с Вашими знаниями" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.MyKnowledgeDescription), Items = null, }); //генератор знаний AddSectionIfNeed(SectionId.KnowledgeGenerator, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Генератор знаний", Url = Url.Action("Index", RouteConfig.KNOWLEDGE_GENERATOR_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к генератору знаний" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.KnowledgeGeneratorDescription), Items = null, }); //видео AddSectionIfNeed(SectionId.Video, model, () => { IVideosQuery videosQuery = new VideosQuery(languageId); List <VideoForUser> videos = videosQuery.GetVisible(VideoType.Clip, COUNT); return(new DescriptionSection { Title = new DescriptionTitle { Title = "Видеоролики", Url = Url.Action("Index", RouteConfig.VIDEO_CONTROLLER, new { type = VideoType.Clip }, Request.Url.Scheme), Description = "Перейти ко всем видеороликам" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.VideoDescription), MostPopularTitle = "5 наиболее популярных видеороликов:", Items = ConvertToItems(videos, e => e.Title), TitleItemGetter = item => WebSettingsConfig.Instance.GetTemplateText(SectionId.Video, PageId.Index, TemplateId.ItemTipOnMainPage, item.Title), UrlItemGetter = item => @Url.Action("Detail", RouteConfig.VIDEO_CONTROLLER, new { group = item.Title + "/" }, Request.Url.Scheme), UrlImageItemGetter = item => Url.Action("GetImageByName", RouteConfig.VIDEO_CONTROLLER, new { group = item.Title }, Request.Url.Scheme), }); }); //задания AddSectionIfNeed(SectionId.UserTasks, model, () => { return(new DescriptionSection { Title = new DescriptionTitle { Title = "Задания", Url = Url.Action("Index", RouteConfig.USER_TASKS_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к заданиям пользователей" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.UserTasksDescription) }); }); //предложения AddSectionIfNeed(SectionId.Sentences, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Предложения", Url = Url.Action("Index", RouteConfig.HOME_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к предложениям" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.SentencesDescription), Items = null, }); //аудирование AddSectionIfNeed(SectionId.Audio, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Аудирование", Url = Url.Action("Index", RouteConfig.AUDIO_WORDS_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к аудированию" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.AudioDescription), Items = null, }); //перевод слов AddSectionIfNeed(SectionId.WordTranslation, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Перевод слов", Url = Url.Action("Index", RouteConfig.WORDS_TRANSLATION_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к переводу слов" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.WordTranslationDescription), Items = null, }); //перевод фразовых глаголов AddSectionIfNeed(SectionId.PhraseVerbTranslation, model, () => new DescriptionSection { Title = new DescriptionTitle { Title = "Перевод фразовых глаголов", Url = Url.Action("Index", RouteConfig.PHRASAL_VERBS_TRANLATION_CONTROLLER, null, Request.Url.Scheme), Description = "Перейти к переводу фразовых глаголов" }, Description = WebSettingsConfig.Instance.GetTemplateText(SectionId.Main, TemplateId.PhrasalVerbsTranslationDescription), Items = null, }); return(View(model)); }
private static void WriteUrls(XElement root) { var sitemapItemWriter = new SitemapItemWriter(); sitemapItemWriter.WriteUrlToResult(root, "", 1); UserLanguages userLanguages = WebSettingsConfig.Instance.DefaultUserLanguages; long languageId = WebSettingsConfig.Instance.GetLanguageFromId(); if (UserLanguages.IsInvalid(userLanguages) || IdValidator.IsInvalid(languageId)) { return; } var visualDictionariesSalesSettings = WebSettingsConfig.Instance.GetSalesSettings(SectionId.VisualDictionary); if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.VisualDictionary)) { var visualDictionariesWriter = new VisualDictionariesWriter(languageId); visualDictionariesWriter.WriteDictionaries(root, visualDictionariesSalesSettings); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.GroupByWords)) { var groupWordsWriter = new GroupWordsWriter(userLanguages, languageId); groupWordsWriter.WriteGroups(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.GroupByPhrases)) { var groupSentencesWriter = new GroupSentencesWriter(userLanguages, languageId); groupSentencesWriter.WriteGroups(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.FillDifference)) { var comparisonsWriter = new ComparisonsWriter(languageId); comparisonsWriter.WriteComparisons(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.PopularWord)) { string knowledgeGeneratorUrl = UrlBuilder.GetPopularWordsUrl(); sitemapItemWriter.WriteUrlToResult(root, knowledgeGeneratorUrl, 0.5m, ChangeFrequency.YEARLY); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.UserTasks)) { var userTasksWriter = new UserTasksWriter(); userTasksWriter.WriteTasks(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.KnowledgeGenerator)) { string knowledgeGeneratorUrl = UrlBuilder.GetKnowledgeGeneratorUrl(); sitemapItemWriter.WriteUrlToResult(root, knowledgeGeneratorUrl, 0.4m, ChangeFrequency.ALWAYS); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.Video)) { var videosWriter = new VideosWriter(languageId); videosWriter.WriteVideos(root, VideoType.Clip); videosWriter.WriteVideos(root, VideoType.Movie); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.TVSeries)) { var videosWriter = new TVSeriesWriter(languageId); videosWriter.WriteTVSeries(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.Sentences)) { var homeWriter = new HomeWriter(userLanguages); homeWriter.Write(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.Audio)) { var audioWordsWriter = new AudioWordsWriter(userLanguages); audioWordsWriter.Write(root); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.WordTranslation)) { sitemapItemWriter.WriteUrlToResult(root, UrlBuilder.GetTranslationDefaulUrl( RouteConfig.WORDS_TRANSLATION_CONTROLLER), 0.1m, ChangeFrequency.MONTHLY); } if (WebSettingsConfig.Instance.IsSectionAllowed(SectionId.PhraseVerbTranslation)) { sitemapItemWriter.WriteUrlToResult(root, UrlBuilder.GetTranslationDefaulUrl( RouteConfig.PHRASAL_VERBS_TRANLATION_CONTROLLER), 0.1m, ChangeFrequency.MONTHLY); } }