Example #1
0
        public ActionResult AddToLearned(int fileId, string[] words)
        {
            _documentWords = new WordInfoXmlSource(ServerPath.MapDocumentPath(fileId.ToString()));
            _learnedWords  = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(UserName));
            foreach (string word in words)
            {
                var wordInfo = _documentWords.Get(w => w.WordString == word);
                wordInfo.Status = Models.WordStatus.Learned;

                LearnWord outValue;
                bool      learned = _learnedWords.IsLearned(word, out outValue);

                if (learned)
                {
                    outValue.Documents.Add(fileId);
                }
                else
                {
                    outValue = new LearnWord {
                        WordString = word, Documents = new List <int> {
                            fileId
                        }
                    };
                    _learnedWords.Add(outValue);
                }
            }

            _documentWords.Save();
            _learnedWords.Save();
            return(RedirectToAction("Load", "Home", new { fileId = fileId }));
        }
Example #2
0
        // GET: Word

        public ActionResult Index()
        {
            _learnedWords = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(UserName));
            var words = _learnedWords.GetAll().ToList();

            return(View(words));
        }