Aug 13, 2013, 5:30 PM
[CLOSED] StoreDataHandler Refresh
I have a StoreForModel which has the following SyncUrl:
.Store(X.StoreForModel().ID("FeatureStore")
.AutoSync(true)
.ShowWarningOnFailure(true)
.Listeners(l =>
{
l.Exception.Fn = "onStoreException";
})
.SyncUrl(Url.Action("HandleFeatureChanges"))
.PageSize(15)
)
public ActionResult HandleFeatureChanges(StoreDataHandler handler)
{
List<FeatureViewModel> records = handler.ObjectData<FeatureViewModel>();
User user = UserHelper.GetUser();
#region db update
if (handler.Action == StoreAction.Create)
{
foreach (FeatureViewModel created in records)
{
created.Add(created, user);
}
}
else if (handler.Action == StoreAction.Destroy)
{
foreach (FeatureViewModel deleted in records)
{
//FeatureViewModel.Delete(deleted.FeatureIDN);
}
}
else if (handler.Action == StoreAction.Update)
{
foreach (FeatureViewModel updated in records)
{
updated.Update(updated, user);
updated.UpdateDate = DateTime.Now;
}
}
#endregion
List<FeatureViewModel> dbRecords = FeatureViewModel.FeatureViewModelFromFeature(_db.Features.ToList());
// DOES NOT WORK
var store = this.GetCmp<Store>("FeatureStore");
store.LoadData(dbRecords);
// DOES NOT WORK
//return handler.Action != StoreAction.Destroy
// ? (ActionResult)this.Store(dbRecords)
// : (ActionResult)this.Content("");
return handler.Action != StoreAction.Destroy
? (ActionResult)this.Store(records)
: (ActionResult)this.Content("");
}
I would like to refresh the Store with data from a database, not the data submitted in form. This way I can get newly added primary keys and database defaults. Please advise.
Last edited by Daniil; Aug 20, 2013 at 9:12 AM.
Reason: [CLOSED]