use this api controller:
public class PersonController:ApiController
{
// other codes...
public HttpResponseMessage PostNewPersons(IEnumerable<PesonDTO> people)
{
foreach (PersonDTO dto in people)
_personAppSrv.Create(dto);
return new HttpResponseMessage(HttpStatusCode.Created);
}
// other codes...
}
use DataSource in webpage:
var ds = new kendo.data.DataSource(
{
transport:{
create: {
url: "/api/person",
dataType: "json",
type:"Post",
contentType: 'application/json;charset=utf-8' // important!!
},
//other codes
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return JSON.stringify(options.models);
}
},
batch:true,
//other codes
});
I use gird to run batch operation like example. If I don't set contentType to 'application/json;' in code above, the request content's contentType is 'application/x-www-form-urlencoded'! Then the api controller can't convert request content data to 'PersonDTO' instance. If I set it, it works well.
If anyone has more better solution, please tell me ,thanks.
public class PersonController:ApiController
{
// other codes...
public HttpResponseMessage PostNewPersons(IEnumerable<PesonDTO> people)
{
foreach (PersonDTO dto in people)
_personAppSrv.Create(dto);
return new HttpResponseMessage(HttpStatusCode.Created);
}
// other codes...
}
use DataSource in webpage:
var ds = new kendo.data.DataSource(
{
transport:{
create: {
url: "/api/person",
dataType: "json",
type:"Post",
contentType: 'application/json;charset=utf-8' // important!!
},
//other codes
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return JSON.stringify(options.models);
}
},
batch:true,
//other codes
});
I use gird to run batch operation like example. If I don't set contentType to 'application/json;' in code above, the request content's contentType is 'application/x-www-form-urlencoded'! Then the api controller can't convert request content data to 'PersonDTO' instance. If I set it, it works well.
If anyone has more better solution, please tell me ,thanks.