protected IHttpActionResult Response(AppMessage message) { var dto = new AppMessageDto(message); var responseMsg = CreateErrorResponse(message); return(ResponseMessage(responseMsg)); }
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()) }); }