Example #1
0
        public HttpResponseMessage Put(HttpRequestMessage request, PostTagViewModel postTagVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var postTagDb = _postTagService.GetByID(postTagVm.PostID, postTagVm.TagID);
                    postTagDb.UpdatePostTag(postTagVm);
                    _postTagService.Update(postTagDb);
                    _postTagService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                return response;
            }));
        }