0

During the Bi-weekly sessions I did come across a mentioned fact that "ViewModels can also be used to update data into the database".

To update "changed" data into the database, I usually send the updated data back to the server as a JSON and after deserializing and looping the data, I manually update every attribute of a class to update the data.

To give a basic idea about our project setup, we have built our own "hybrid" ViewModel designer by which we generate the .spans XML by ourselves. Therefore we've never used the ViewModel designer that resides in the Modlr.

We use the below code to load the ViewModel at runtime basis of the current active page

var vmname = Path.GetFileNameWithoutExtension(file);
var path = "<Some File Path Here>";
var xd = XDocument.Load(path + "\\" + file);
var vmc = new ViewModelRTCreator(xd);
ViewModelDefinitionsInApplication.InjectViewModelWithName(vmname, vmc, this.EcoSpace.GetType());
var vm = ViewModelHelper.CreateFromViewModel(<Spans Name>, this.EcoSpace, <Some Root Object>);

Our server has been set up to provide RESTful services to all applications requesting data and therefore, there's a disconnect between data that's being sent as JSON and the ViewModel itself (we aren't using MDriven Turnkey).

Could you point me in the right direction or refer some wiki article that we may have so that I can achieve the same.

1 Answers1

0

Start by reviewing this wiki page: https://wiki.mdriven.net/index.php/Rest_Services_In_MDriven

The second part is about exposing viewmodels as rest interfaces.

That article also points to this video: https://youtu.be/rv31ziYXWME

Lars
  • 191
  • 4