public static IListData GenerateVMData(LuaTable luaData) { LuaTable listLua = luaData.Get <LuaTable>("__vm_value"); LuaTable first = listLua.Get <int, LuaTable>(1); IListData listData = CreateListDataInstanceWithItemLuaTable(first); listData.DisableValueChangeHandler = true; listLua.ForEach <int, LuaTable>(delegate(int index, LuaTable item) { listData.Add(XLuaData.GenerateDataWithLuaTable(item)); }); listData.DisableValueChangeHandler = false; listData.InvokeValueChanged(); luaData.Set <string, Action <LuaTable> >("__vm_list_add", delegate(LuaTable item) { listData.AddItem(XLuaData.GenerateDataWithLuaTable(item)); }); luaData.Set <string, Action <int, LuaTable> >("__vm_list_insert", delegate(int index, LuaTable item) { listData.InsertItem(index - 1, XLuaData.GenerateDataWithLuaTable(item)); }); luaData.Set <string, Action>("__vm_list_pop", delegate() { listData.RemoveAt(listData.Count - 1); }); luaData.Set <string, Action <int> >("__vm_list_remove", delegate(int index) { listData.RemoveAt(index - 1); }); luaData.Set <string, Action>("__vm_list_reorder", delegate() { listData.DisableValueChangeHandler = true; LuaTable newListLua = luaData.Get <LuaTable>("__vm_value"); listData.Clear(); newListLua.ForEach <int, LuaTable>(delegate(int index, LuaTable item) { listData.Add(XLuaData.GenerateDataWithLuaTable(item)); }); listData.DisableValueChangeHandler = false; listData.InvokeValueChanged(); }); return(listData); }
public async Task <IActionResult> Create(ToDoList model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(User.Identity.Name); var temp = new ToDoList() { Name = model.Name, Duration = model.Duration, UserId = user.Id }; data.Add(temp); data.commit(); return(RedirectToAction("Display", "Account")); } return(View(model)); }