public IActionResult OnPostSave(List <ECourseInfo> couseList, List <ECourseInfoClass> classList) { ResultList <SlKiV> result = new ResultList <SlKiV>(); bool needSave = false; try { _CourseSrv.BeginTrans(); result.List = new List <SlKiV>(); if (couseList.Count > 0) { _CourseSrv.DelByType(couseList[0].CourseType); foreach (var obj in couseList) { _CourseSrv.Add(obj, false); result.List.Add(new SlKiV { Key = obj.Id, Value = obj.Level }); } needSave = true; } if (classList.Count > 0) { foreach (var cls in classList) { _CourseSrv.CreateOrUpdateClass(cls); } } if (needSave) { _CourseSrv.SaveChanges(); } _CourseSrv.CommitTrans(); } catch (Exception ex) { _CourseSrv.RollBackTrans(); result.ErrorMsg = ex.Message; } return(new JsonResult(result)); }