예제 #1
0
        protected IHttpActionResult Response(AppMessage message)
        {
            var dto         = new AppMessageDto(message);
            var responseMsg = CreateErrorResponse(message);

            return(ResponseMessage(responseMsg));
        }
예제 #2
0
        private HttpResponseMessage CreateErrorResponse(AppMessage appMessage)
        {
            var request = HttpContext.Current.Items["MS_HttpRequestMessage"] as HttpRequestMessage;
            var dto     = new AppMessageDto(appMessage);

            return(new HttpResponseMessage(appMessage.HttpStatusCode)
            {
                ReasonPhrase = appMessage.Code + ": " + appMessage.Description,
                RequestMessage = request,
                Content = new ObjectContent(dto.GetType(), dto, new JsonMediaTypeFormatter())
            });
        }