Kendo UI grid Create action passes null reference from WCF service -
i struggling calling create action through wcf service kendo ui grid.when odataservice calls business logic controller write record passes null reference....the customer object populated until call business logic createentity method. thought because of content type having doubts now. accessing wcf service directly fiddler creates record...
kendo grid:
here application level customer_create action being called kendo grid
@(html.kendo().grid<application.serviceproxy.customerdto>() .name("grid") .columns(columns => { columns.bound(c => c.salesorganizationid).width(15).title("sales org"); columns.bound(c => c.customerid).width(20).groupable(false); columns.bound(c => c.name1).width(25).title("name"); columns.bound(c => c.city).width(15).title("city"); columns.bound(c => c.statecode).width(10).title("state"); columns.bound(c => c.countrycode).width(15).title("country"); columns.bound(c => c.matchcode).width(25).title("matchcode"); columns.command(command => { command.edit(); command.destroy(); }).width(35); //add program type here cmi, vmi etc.. //columns.width(25).title("program"); }) .toolbar(toolbar => toolbar.create()) .editable(ed => ed.mode(grideditmode.popup).window(w => w.title("edit customer details").name("editwindow").htmlattributes(new { @style = "width:700px;" }))) .pageable() .sortable() .groupable() .scrollable() .filterable() .htmlattributes(new { style = "height:420px;" }) .datasource(datasource => datasource .ajax() .pagesize(20) .serveroperation(true) .events(events => events.error("error_handler")) .model(model => model.id(c => c.customerid)) .create(update => update.action("customer_create", "customer")) .read(read => read.action("customer_read", "customer")) .update(update => update.action("customer_update", "customer")) .destroy(update => update.action("customer_delete", "customer")) )
)
here application level customer_create action being called kendo grid
[system.web.http.httppost] public actionresult customer_create([datasourcerequest] datasourcerequest request, application.serviceproxy.customerdto customer) { if (customer != null && modelstate.isvalid) { var odataservice = new container(new uri("http://localhost:8089/odata/")); //odataservice.r odataservice.addtocustomer(customer); odataservice.savechanges(); return json(modelstate.todatasourceresult()); } return view("index"); }
here createentity method being called through generated wcf data service.
protected override customerdto createentity(customerdto customerdto) { var customer = new customer() { matchcode = customerdto.matchcode, salesorganizationid = customerdto.salesorganizationid, statusid = customerdto.statusid, servicelevelstatusid = customerdto.servicelevelstatusid, mediaidlogo = customerdto.mediaidlogo, systemid = customerdto.systemid, customerexternalsystemid = customerdto.customerexternalsystemid, internationalgroup = customerdto.internationalgroup, division = customerdto.division, corporateid = customerdto.corporateid, inventorymanagerid = customerdto.inventorymanagerid, dunsnumber = customerdto.dunsnumber }; entity.customer.add(customer); entity.savechanges(); return getentitybykey(customer.customerid); }
Comments
Post a Comment