public IHttpActionResult GetOrderById(int id, string fields = "") { if (id <= 0) { return(Error(HttpStatusCode.BadRequest, "id", "invalid id")); } Order order = _orderApiService.GetOrderById(id); if (order == null) { return(Error(HttpStatusCode.NotFound, "order", "not found")); } var ordersRootObject = new OrdersRootObject(); OrderDto orderDto = order.ToDto(); ordersRootObject.Orders.Add(orderDto); var json = _jsonFieldsSerializer.Serialize(ordersRootObject, fields); return(new RawJsonActionResult(json)); }