public ActionResult Update([DataSourceRequest] DataSourceRequest request, TweetAdministrationViewModel tweet)
        {
            if (tweet != null && ModelState.IsValid)
            {
                var existingTweet = this.Data.Tweets.GetById(tweet.Id);

                existingTweet.Content = tweet.Content;

                this.Data.SaveChanges();

                var hashTags = GetHashTags(tweet.Content);
                existingTweet.HashTags.Clear();

                foreach (var hashTag in hashTags)
                {
                    var resultHashTag = this.CreateOrUpdateHashTag(hashTag);
                    existingTweet.HashTags.Add(resultHashTag);
                    this.Data.HashTags.Update(resultHashTag);
                }

                this.Data.Tweets.Update(existingTweet);
                this.Data.SaveChanges();
            }

            return(Json(new[] { tweet }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, TweetAdministrationViewModel tweet)
        {
            if (tweet != null && ModelState.IsValid)
            {
                try
                {
                    this.Data.Tweets.Delete(tweet.Id);
                    this.Data.SaveChanges();
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }

            return(Json(new[] { tweet }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, TweetAdministrationViewModel tweet)
        {
            if (tweet != null && this.ModelState.IsValid)
            {
                try
                {
                    this.data.Tweets.Delete(tweet.Id);
                    this.data.SaveChanges();
                }
                catch (Exception ex)
                {
                    this.ModelState.AddModelError(string.Empty, ex.Message);
                }
            }

            return Json(new[] { tweet }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, TweetAdministrationViewModel tweet)
        {
            if (tweet != null && this.ModelState.IsValid)
            {
                var existingTweet = this.data.Tweets.GetById(tweet.Id);

                existingTweet.Content = tweet.Content;
                this.data.SaveChanges();

                var hashTags = GetHashTags(tweet.Content);
                foreach (var hashTag in hashTags)
                {
                    var resultHashTag = this.CreateOrUpdateHashTag(hashTag);
                    existingTweet.HashTags.Add(resultHashTag);
                    this.data.HashTags.Update(resultHashTag);
                }

                this.data.Tweets.Update(existingTweet);
                this.data.SaveChanges();
            }

            return Json(new[] { tweet }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }