コード例 #1
0
 public HttpResponseMessage Update(HttpRequestMessage request, PostTagModel PostTagModel)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var PostTagService = new PostTagService();
             PostTagService.Update(PostTagModel);
             response = request.CreateResponse(HttpStatusCode.OK);
         }
         return response;
     }));
 }
コード例 #2
0
        public async Task <ActionResult <ResultOutDto <object> > > PutPostTags(
            [FromRoute] int id, [FromBody] PostTag tag
            )
        {
            if (id != tag.Id)
            {
                return(BadRequest(ResultOutDtoBuilder.Fail <object>(new FormatException(), "error id format")));
            }

            try
            {
                await _postTagService.Update(tag);

                return(NoContent());
            }
            catch (NotExistedException e)
            {
                return(NotFound(ResultOutDtoBuilder.Fail <object>(e, "Not exist.")));
            }
            catch (ExistedConflictException e)
            {
                return(Conflict(ResultOutDtoBuilder.Fail <object>(e, "Conflict name.")));
            }
        }