Esempio n. 1
0
        /// <summary>
        /// Posts a new comment.
        /// </summary>
        /// <param name="item">New comment</param>
        /// <returns>Status message</returns>
        public async Task<Comment> Post(Comment item)
        {
            if (item == null)
            {
                throw new HttpResponseException(
                    Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid parameter"));
            }

            var comment = await repository.InsertAsync(item);
            return comment;
        }
Esempio n. 2
0
        /// <summary>
        /// Updates an existing comment.
        /// </summary>
        /// <param name="key">Comment ID</param>
        /// <param name="item">Updated comment</param>
        /// <returns>Status message</returns>
        public async Task<Comment> Put([FromODataUri] Guid key, Comment item)
        {
            if (key == Guid.Empty || item == null)
            {
                throw new HttpResponseException(
                    Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid parameter"));
            }

            item.ID = key;
            var comment = await repository.UpdateAsync(item);
            return comment;
        }