// PUT api/comments/5
        public void Put(int id, [FromBody] Comment comment)
        {
            var existing = this.Get(id);

            if (existing == null)
            {
                throw new Exception("Not found");
            }

            existing.Content = comment.Content;

            context.Update(existing);
            context.SaveChanges();
        }
Esempio n. 2
0
        // PUT api/posts/5
        public void Put(int id, [FromBody] Post post)
        {
            var existing = this.Get(id);

            if (existing == null)
            {
                throw new KeyNotFoundException();
            }

            existing.Content = post.Content;
            existing.Title   = post.Title;

            context.Update(existing);
            context.SaveChanges();
        }