//combine text in textList with: 1. ID 2.CaseText 3.CaseIntro with the splitter: ~ public ActionResult UpdateGroupText(int tchRoutineID, List <string> textList) { using (FATContainer dataContainer = new FATContainer()) { foreach (string strVar in textList) { string[] arr = strVar.Split('~'); RoutineGroup groupObj = dataContainer.RoutineGroup.Find(Convert.ToInt32(arr[0])); groupObj.GroupText = arr[1]; groupObj.RoutineIntro = arr[2]; } dataContainer.SaveChanges(); } SharedCasePool.GetCasePool().ReloadRoutine(tchRoutineID); JsonResult result = new JsonResult(); result.Data = string.Empty; return(result); }
public ActionResult AppendCase(TeachingRoutine routine) { using (FATContainer dataContainer = new FATContainer()) { dataContainer.TeachingRoutine.Add(routine); dataContainer.SaveChanges(); var tempateNodeList = from node in dataContainer.TemplateNode where node.RoutineID == routine.TmpRoutineID orderby node.NodeIndex select node; List <TeachingNode> tchNodeList = new List <TeachingNode>(); foreach (TemplateNode tmpNode in tempateNodeList) { TeachingNode newNode = new TeachingNode() { CurrStatus = 0, RelTmpNode = tmpNode, RoutineID = routine.Row_ID, TmpNodeID = tmpNode.Row_ID }; tchNodeList.Add(newNode); dataContainer.TeachingNode.Add(newNode); } dataContainer.SaveChanges(); string currPhaseName = string.Empty; foreach (TeachingNode tchNode in tchNodeList) { switch (tchNode.NodeTag) { case "Guide": { currPhaseName = tchNode.NodeName; RoutineGroup group = dataContainer.RoutineGroup.Create(); group.GroupText = string.Empty; group.GroupIdx = tchNode.GroupIdx; group.TchRoutineID = routine.Row_ID; group.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; group.RoutineIntro = string.Empty; dataContainer.RoutineGroup.Add(group); break; } #region common node case "DetailedLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { DetailedLedger info = dataContainer.DetailedLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.DetailedLedger.Add(info); } break; } case "CashJournal": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CashJournal info = dataContainer.CashJournal.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.CashJournal.Add(info); } break; } case "OuterSubject": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { OuterSubject info = dataContainer.OuterSubject.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.OuterSubject.Add(info); } break; } case "CustomerLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CustomerLedger info = dataContainer.CustomerLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; info.BalanceTime = DateTime.Now; dataContainer.CustomerLedger.Add(info); } break; } case "GeneralLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { GeneralLedger info = dataContainer.GeneralLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.GeneralLedger.Add(info); } break; } default: { if (tchNode.RelTmpNode.NodeType == "SpecialNode") { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { SubjectItem info = dataContainer.SubjectItem.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; dataContainer.SubjectItem.Add(info); } } break; } #endregion #region special node #endregion } } dataContainer.SaveChanges(); } JsonResult result = new JsonResult(); result.Data = routine; return(result); }