public PartialViewResult AddPhrases(string text) { string[] stringSeparators = new string[] { "\r\n" }; string[] phrases = text.Split(stringSeparators, StringSplitOptions.None); for (int i = 0; i < phrases.Length; i++) { var phrase = phrases[i]; if (!string.IsNullOrEmpty(phrase) && _data.SingleOrDefault(x => x.Text == phrase) == null) { var model = new VMSeoPhrase(phrase); model.WordCount = _counter.GetWordCount(model); _data.Add(model); } } return PartialView("_Table", _data.ToArray()); }
public int GetWordCount(VMSeoPhrase phrases) { string[] res = phrases.Text.Trim().Split(' '); return res.Length; }