Exemplo n.º 1
0
        public void NotFoundDtoTest()
        {
            var dto1 = NotFoundDto.ParentNotFound("parentId");
            var dto2 = NotFoundDto.ResourceNotFound("resourceId");

            Assert.AreEqual("404 Not Found", dto1.Error);
            Assert.AreEqual("Parent with ID parentId was not found.", dto1.ErrorDescription);

            Assert.AreEqual("404 Not Found", dto2.Error);
            Assert.AreEqual("Resource with ID resourceId was not found.", dto2.ErrorDescription);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns an HttpResponseMessage as a HttpStatusCode.NotFound (404) with a standardized response for resources not found.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public static HttpResponseMessage CreateNotFoundResponse(this HttpRequestMessage request, string message)
 {
     var response = new NotFoundDto();
     response.message = message;
     return request.CreateResponse(HttpStatusCode.InternalServerError, response);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns an HttpResponseMessage as a HttpStatusCode.NotFound (404) with a standardized response for resources not found.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public static HttpResponseMessage CreateNotFoundResponse(this HttpRequestMessage request)
 {
     var response = new NotFoundDto();
     return request.CreateResponse(HttpStatusCode.NotFound, response);
 }