public IHttpActionResult PutSavedSocialMessage(int id, SavedSocialMessage savedSocialMessage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != savedSocialMessage.Id)
            {
                return(BadRequest());
            }

            db.Entry(savedSocialMessage).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SavedSocialMessageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetSavedSocialMessage(int id)
        {
            SavedSocialMessage savedSocialMessage = db.SavedSocialMessages.Find(id);

            if (savedSocialMessage == null)
            {
                return(NotFound());
            }

            return(Ok(savedSocialMessage));
        }
        public IHttpActionResult PostSavedSocialMessage(SavedSocialMessage savedSocialMessage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //savedSocialMessage.PostTimeStamp = DateTime.Now;
            db.SavedSocialMessages.Add(savedSocialMessage);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = savedSocialMessage.Id }, savedSocialMessage));
        }
        public IHttpActionResult DeleteSavedSocialMessage(int id)
        {
            SavedSocialMessage savedSocialMessage = db.SavedSocialMessages.Find(id);

            if (savedSocialMessage == null)
            {
                return(NotFound());
            }

            db.SavedSocialMessages.Remove(savedSocialMessage);
            db.SaveChanges();

            return(Ok(savedSocialMessage));
        }
        public ActionResult Delete(int id, int playListId)
        {
            SavedSocialMessage savedSocialMessage = db.SavedSocialMessages.Find(id);

            db.SavedSocialMessages.Remove(savedSocialMessage);
            db.SaveChanges();

            var rv        = db.Playlists.Select(s => new { Playlist = s, Message = s.SavedSocialMessage, }).First(f => f.Playlist.Id == playListId);
            var playLists = db.Playlists.ToList();
            var vm        = new PlaylistWithSocialMessagesVM
            {
                Messages     = rv.Message,
                PlayListName = rv.Playlist.PlaylistName,
                AllPlaylist  = playLists,
                Id           = id
            };

            return(PartialView("_PlaylistSearchResultsPartial", vm));
        }
        public ActionResult EditMessage(int id, int playListId, string newText)
        {
            SavedSocialMessage savedSocialMessage = db.SavedSocialMessages.Find(id);

            savedSocialMessage.Text            = newText;
            db.Entry(savedSocialMessage).State = EntityState.Modified;
            db.SaveChanges();

            var rv        = db.Playlists.Select(s => new { Playlist = s, Message = s.SavedSocialMessage, }).First(f => f.Playlist.Id == playListId); //take this and put in seperate controller return a partial that is the html.
            var playLists = db.Playlists.ToList();
            var vm        = new PlaylistWithSocialMessagesVM
            {
                Messages     = rv.Message,
                PlayListName = rv.Playlist.PlaylistName,
                AllPlaylist  = playLists,
                Id           = id
            };

            return(PartialView("_PlaylistSearchResultsPartial", vm));
        }