Esempio n. 1
0
        public ActionResult ParseWords(ParseWordsViewModel parseWordsViewModel)
        {
            var parsedWordsViewModel = new ParsedWordsViewModel();

            try
            {
                parsedWordsViewModel.Languages = _polyglotListsService.GetLanguaches().ToSeletListItems(l => l.Name, l => l.Id, 1);
                parsedWordsViewModel.Statuses  = _polyglotListsService.GetWordStatuses().ToSeletListItems(s => s.Name, s => s.Id, 1);
                parsedWordsViewModel.Sets      = _userWordsService.GetUserWordsSets(this.GetAppUserId()).Select(s => s.Name).ToList();
                parsedWordsViewModel.SetName   = parsedWordsViewModel.Sets.FirstOrDefault();
                IEnumerable <WordInfo> parsedWords = _foreignTexServise.ParseWords(parseWordsViewModel.Text, parseWordsViewModel.SeparatorsArr);

                if (parseWordsViewModel.ExcludeExists)
                {
                    var existsWords = _userWordsService.GetUserWords().Select(w => w.Word.Text).ToList();
                    parsedWords = parsedWords.Where(w => !existsWords.Contains(w.Word));
                }

                parsedWordsViewModel.WordsJson = JsonConvert.SerializeObject(parsedWords.Select(w => new { w.Word, w.Count, id = Guid.NewGuid() }));

                //FillListsParseWordsVM(ref parseWordsViewModel);
            }
            catch (Exception ex)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.OK, ex.CollectMessages());
                ModelState.AddModelError("", ex.CollectMessages());
            }
            return(PartialView("_ParsedWords", parsedWordsViewModel));
        }
Esempio n. 2
0
        public ActionResult ParseWords(int?foreignText_Id)
        {
            ParseWordsViewModel viewModel = new ParseWordsViewModel();

            viewModel.SeparatorsArr = _foreignTexServise.GetDefaultSeparators();
            if (foreignText_Id.HasValue)
            {
                ForeignText text = _foreignTexServise.GetUserTexts().First(t => t.Id == foreignText_Id.Value);
                viewModel.Text = text.Text;
            }
            //FillListsParseWordsVM(ref viewModel);

            return(View(viewModel));
        }