What do I need to do to allow posting back changes to the DataController?
I have an EmployeeDataController : DataController. Getting and binding/displaying the data is working fine so far.
But when I try to save changes I am running into problems.
First when Html.UpshotContext(false)
If I override the ExecuteAsync method in my EmployeeDataController it does get called when an item is changed but the ChangeSet is null. None of the other methods I have overridden (PersistChangeSet, Submit etc) are ever called.
Second if Html.UpshotContext(true) and add
self.saveAll = function () { self.dataSource.commitChanges() }
However I am still not getting any call backs. When stepping through I see in the upshot method
_commitChanges
that the options url = "/api/Employee?action=" and the opertationName = GetEmployees (which was defined in
@(Html.UpshotContext(bufferChanges:=true).DataSource(Of EmployeeDataController)(Function(x) x.GetEmployees()))
I am guessing there is someplace to define the operation for the commitChanges but I haven't figured that out yet.
*Edit I have fixed the runtime error I mentioned before.
I've created a controller that extends the DataController and can retrieve an IQuerable collection and can bind the items to elements on the page.
When trying to commit changes back to the server I also noticed that the Submit method is not invoked, as it is in Steve Sanderson's DeliveryTracker SPA demo.
When stepping through the Upshot code I noticed that the remote data source URL is set to "/api/Controller?action=" rather than "api/Controller" as it is in Steve Sanderson's demo.
Also when stepping through the code the _commitChanges eventually concats "/Submit" to the URL, so "api/Controller?action=" becomes "api/Controller?action=/Submit" and then Upshot makes a Jquery ajax call to this url. The ajax call returns a 405 error with
the message "The requested resource does not support http method 'POST'".
My initial thoughts are that the remote data source URL format, "api/Controller?action=" is the issue.
@el_gringo_grande please update this post if you get any further with this issue and I will do the same.
Hello. Could you please share a sample. There is no sample from Microsoft without DbDataController and so the samples don't really help with creating real applications that actually have a business layer. I would very much appreciate seeing a sample that
uses a controlle that derive from DataController and uses the Repository pattern.
el_gringo_gr...
Member
2 Points
9 Posts
commitChanges on DataSource using DataController
Mar 27, 2012 04:03 PM|LINK
What do I need to do to allow posting back changes to the DataController?
I have an EmployeeDataController : DataController. Getting and binding/displaying the data is working fine so far.
But when I try to save changes I am running into problems.
First when Html.UpshotContext(false)
If I override the ExecuteAsync method in my EmployeeDataController it does get called when an item is changed but the ChangeSet is null. None of the other methods I have overridden (PersistChangeSet, Submit etc) are ever called.
Second if Html.UpshotContext(true) and add
self.saveAll = function () { self.dataSource.commitChanges() }
However I am still not getting any call backs. When stepping through I see in the upshot method
_commitChanges
that the options url = "/api/Employee?action=" and the opertationName = GetEmployees (which was defined in
@(Html.UpshotContext(bufferChanges:=true).DataSource(Of EmployeeDataController)(Function(x) x.GetEmployees()))
I am guessing there is someplace to define the operation for the commitChanges but I haven't figured that out yet.
*Edit I have fixed the runtime error I mentioned before.
AnishPatelDo...
Member
14 Points
2 Posts
Re: commitChanges on DataSource using DataController
Mar 29, 2012 01:26 PM|LINK
I'm in the same situation as you.
I've created a controller that extends the DataController and can retrieve an IQuerable collection and can bind the items to elements on the page.
When trying to commit changes back to the server I also noticed that the Submit method is not invoked, as it is in Steve Sanderson's DeliveryTracker SPA demo.
When stepping through the Upshot code I noticed that the remote data source URL is set to "/api/Controller?action=" rather than "api/Controller" as it is in Steve Sanderson's demo.
Also when stepping through the code the _commitChanges eventually concats "/Submit" to the URL, so "api/Controller?action=" becomes "api/Controller?action=/Submit" and then Upshot makes a Jquery ajax call to this url. The ajax call returns a 405 error with the message "The requested resource does not support http method 'POST'".
My initial thoughts are that the remote data source URL format, "api/Controller?action=" is the issue.
@el_gringo_grande please update this post if you get any further with this issue and I will do the same.
AnishPatelDo...
Member
14 Points
2 Posts
Re: commitChanges on DataSource using DataController
Mar 29, 2012 03:45 PM|LINK
I fixed this issue and got the Submit method to be called when Upshot invokes _commitChanges.
I changed the default api route from:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
to:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}",
defaults: new { action = RouteParameter.Optional }
);
el_gringo_gr...
Member
2 Points
9 Posts
Re: commitChanges on DataSource using DataController
Mar 29, 2012 08:53 PM|LINK
Ahhhh Excellent! I will give that a try tomorrow.
domokos.lora...
Member
2 Points
1 Post
Re: commitChanges on DataSource using DataController
May 12, 2012 10:44 AM|LINK
Hello. Could you please share a sample. There is no sample from Microsoft without DbDataController and so the samples don't really help with creating real applications that actually have a business layer. I would very much appreciate seeing a sample that uses a controlle that derive from DataController and uses the Repository pattern.