Ejemplo n.º 1
0
 public static HttpResponseMessage CreateResponse(this HttpRequestMessage request, ApiResult result)
 {
     if (result.success)
         return request.CreateResponse(HttpStatusCode.OK, result);
     else
         return request.CreateErrorResponse(HttpStatusCode.InternalServerError, result.message);
 }
Ejemplo n.º 2
0
        public HttpResponseMessage Delete(int id)
        {
            var result = new ApiResult();
            try
            {
                logic.DeleteTask(id);

                result.SetDeleteSuccess("task");
            }
            catch
            {
                result.SetDeleteFailed("task");

                //TODO: Log failure and exception
            }

            return Request.CreateResponse(result);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Post(Task task)
        {
            var result = new ApiResult();

            try
            {
                logic.UpsertTask(task);

                result.SetSavedSuccess("task", new TaskView(task));
            }
            catch
            {
                result.SetSavedFailed("task");

                //TODO: Log failure and exception
            }

            return Request.CreateResponse(result);
        }