public ActionResult BoughtList() { BoughtListViewModel BoutListView; if (TempData["ErrorPage"] != null) { BoutListView = (BoughtListViewModel)TempData["ErrorPage"]; ModelState.Merge((ModelStateDictionary)TempData["ModelState"]); } else { BoutListView = new BoughtListViewModel(); BoutListView.Result = ABS.GetAllData(); } return(View("BoughtList", BoutListView)); }
public ActionResult WriteData(BoughtListViewModel input) { BoughtListViewModel BoutListView = new BoughtListViewModel(); if (ModelState.IsValid) { var flag = ABS.WtrieData(input.InputData); if (flag != true) { BoutListView.InputData.Remark = "出錯啦!!!!"; } BoutListView.Result = ABS.GetAllData(); BoutListView.InputData = new BoughtItem(); return(PartialView("BoughtListGridPartialView", BoutListView)); } TempData["ErrorPage"] = input; TempData["ModelState"] = ModelState; return(JavaScript($"window.location = '{Url.Action("BoughtList")}'")); }