private void GetTags(string tags, Tweet tweet) { var allTags = tags.Split(' '); foreach (var item in allTags) { var newTag = new Tag(); var founTag = this.tagServices.FindByName(item); if (founTag == null) { newTag.Name = item; newTag.IsVisible = true; } else { newTag = founTag; newTag.IsVisible = true; } tweet.Tags.Add(newTag); } }
public void Add(Tweet tweet) { this.tweets.Add(tweet); this.tweets.SaveChanges(); }
public ActionResult PostTweet(TweetInsertViewModel model) { if (!this.ModelState.IsValid) { return RedirectToAction("PostTweet"); } var tweet = new Tweet { CreatedOn = DateTime.Now, Content = model.Content, IsVisible = true, UserId = this.User.Identity.GetUserId(), }; GetTags(model.Tags, tweet); this.tweetServices.Add(tweet); return RedirectToAction("MyTweets"); }
public void Update(Tweet tweet) { this.tweets.Update(tweet); this.tweets.SaveChanges(); }