Пример #1
0
        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);
            }
        }
Пример #2
0
 public void Add(Tweet tweet)
 {
     this.tweets.Add(tweet);
     this.tweets.SaveChanges();
 }
Пример #3
0
        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");
        }
Пример #4
0
 public void Update(Tweet tweet)
 {
     this.tweets.Update(tweet);
     this.tweets.SaveChanges();
 }