public static Container CreateSuccessResponseWithPaging(Encoder encoder, Container paging_request, int total_elements) { var root = encoder.CreateRoot(); var result = encoder.AddContainer(root, "Result"); encoder.AddBoolean(result, "Success", true); var paging = encoder.AddContainer(root, "Paging"); encoder.AddNumber(paging, "PageNumber", IntValue(paging_request.Get("PageNumber"))); encoder.AddNumber(paging, "ElementsPerPage", IntValue(paging_request.Get("ElementsPerPage"))); if (total_elements >= 0) { encoder.AddNumber(paging, "TotalPages", (int)Math.Ceiling((double)total_elements / FloatValue(paging_request.Get("ElementsPerPage")))); encoder.AddNumber(paging, "TotalElements", total_elements); } return(root); }