Hi,
I am starting to work on using Local Storage for my ASP.NET MVC/Web API application.
The application allows a user when in the office to select the run sheet (list of packages to be delivered) and then a copy of all the data for that run sheet gets stored in the local storage of the browser. The user then delivers all the packages, recording the deliveries in local storage and upon returning to the office all the deliveries are transferred from local storage to the database on the server. Or at least that is how it is supposed to work. :)
My problem is that I am getting all the run sheet details from the database and displaying them no problem the first time using his code:
public ActionResult Index(Guid id)
{
RunSheetDetailsListViewModel vm = new RunSheetDetailsListViewModel();
var query = this._unit.RunSheetDetails.GetByRunSheetId(id); //.GetAll().OrderBy(rnh => rnh.Route.rte_name);
vm.RunSheetDetails = query.ToList();
return View("Index", vm);
}
In my Index.cshtml I have this:
var vm = new ViewModel();
var serialized = JSON.stringify(vm.runSheetDetails());
runsheetdetailsDataService.saveLocal(serialized);
in the jquery ready function.
This apparently saves the data properly in the local storage.
Now, when the user is not connected to the server, how do I tell the Index ActionResult to pull the data from local storage rather than the database?