/// <summary>
        ///  Get a word list
        /// </summary>
        /// <param name="text"></param>
        /// <returns> word, frequency, length</returns>
        public List <WordDetail> GetWordDetail(string text)
        {
            WordDetail word;
            var        words           = new List <WordDetail>();
            var        wordFrequencies = GetWordsFrequency(text);

            foreach (var item in wordFrequencies)
            {
                word           = new WordDetail();
                word.Word      = item.Key;
                word.Frequency = item.Value;
                word.Length    = GetWordLength(item.Key);

                // Add item on List
                words.Add(word);
            }
            return(words);
        }
        public ActionResult Edit(Word word)
        {
            if (ModelState.IsValid)
            {
                WordDetail wDetail = db.WordDetail.First(wd => wd.Id == word.WordDetail.Id);
                wDetail.CreatedTime = DateTime.Today;
                wDetail.WContext    = word.WordDetail.WContext;
                wDetail.WPronounce  = word.WordDetail.WPronounce;
                word.WordDetail     = wDetail;
                //word.CreatedTime = word.CreatedTime.AddDays(-1);

                db.Entry(word).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.redirectUrl = Url.Action("details", "words", new { id = word.Id });
                return(PartialView("_RedirectPage"));
            }

            return(View(word));
        }
        public bool CreateMeaning(WordDetail word, MeaningCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = new Meaning()
                {
                    WordName = word.WordName,//

                    WordId          = ctx.Words.Where(e => e.WordName == word.WordName).Select(e => e.WordId).FirstOrDefault(),
                    Pronunciation   = model.Pronunciation,
                    Context         = model.Context,
                    Description     = model.Description,
                    RegionalDialect = (Data.Dialect)model.RegionalDialect,
                    //CumulativeRating = null,
                };
                ctx.Meanings.Add(entity);

                return(ctx.SaveChanges() == 1);
            }
        }