I currently have an example that fires my delete, update, and read methods on my WCF rest service. For whatever reason, I cannot get the create to work. Am I doing something wrong?
<
script
>
$(document).ready(function () {
var crudServiceBaseUrl = "http://localhost/IqaRestService/Service1",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/getquestions",
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "/update",
dataType: "json",
type: "POST",
contentType: "application/json"
},
create: {
url: crudServiceBaseUrl + "/create",
dataType: "json",
type: "POST",
contentType: "application/json"
},
destroy: {
url: crudServiceBaseUrl + "/delete",
dataType: "json",
type: "DELETE",
contentType: "application/json"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options) {
return kendo.stringify({ question: options });
}
}
},
schema: {
model: {
id: "QuestionId",
fields: {
QuestionId: { type: "string" },
QuestionText: { type: "string" },
Comment: { type: "string" },
Answer: { type: "string" }
}
}
}
});
$(".k-add-button").click(function (e) {
listView.add();
e.preventDefault();
});
var listView = $("#listView").kendoListView({
dataSource: dataSource,
editable: true,
selectable: "single",
template: kendo.template($("#template").html()),
editTemplate: kendo.template($("#editTemplate").html())
}).data("kendoListView");
});
</
script
>
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate =
"/getquestions"
)]
public
List<IqaQuestion> GetQuestions()
{
return
this
.Store;
}
[OperationContract]
[WebInvoke(Method =
"POST"
, UriTemplate =
"/update"
, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public
bool
SaveQuestion(IqaQuestion question)
{
return
true
;
}
[OperationContract]
[WebInvoke(Method =
"POST"
, UriTemplate =
"/create"
, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public
bool
CreateQuestion(IqaQuestion question)
{
return
true
;
}
[OperationContract]
[WebInvoke(Method =
"DELETE"
, UriTemplate =
"/delete"
, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public
bool
RemoveQuestion(IqaQuestion question)
{
return
false
;
}