/// <summary> /// Store a new hashtag in the DB. /// </summary> /// <param name="hashtag">The new Hashtag</param> /// <returns>The new ID</returns> public int AddHashtag(Model.Hashtag hashtag) { hashtag.ID = this.GetLastId() + 1; _db.Hashtags.Add(hashtag); _db.SaveChanges(); return(hashtag.ID); }
/// <summary> /// Extracts the hashtags from the entry message. /// </summary> /// <param name="message">The entry's message</param> /// <returns>A List of Hashtags</returns> public List <Model.Hashtag> GetHashtags(string message) { string[] words; List <Model.Hashtag> hashtags = new List <Model.Hashtag>(); words = message.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); int position; Model.Hashtag hashtag; for (int i = 0; i < words.Length; i++) { position = words[i].IndexOf("#"); if (position == 0) { hashtag = new Model.Hashtag(); hashtag.name = words[i]; hashtags.Add(hashtag); } } return(hashtags); }
public ActionResult Search(Model.Hashtag hashtag) { List <Model.Entry> entries = hashtagManager.GetEntriesByHashtagName(hashtag.name); return(View("Index", entries)); }