public async Task<ActionResult> BizCheck02(BizCheck02ViewModel bizCheck02ViewModel) { ViewBag.LeftMenu = Global.Report; int questionSn = bizCheck02ViewModel.QuestionSn; if (bizCheck02ViewModel.QuestionSn > 0) { var quesMaster = await _quesMasterService.GetQuesResult1Async(questionSn); if (bizCheck02ViewModel.SubmitType == "N") { quesMaster.SaveStatus = 5; } foreach(var item in bizCheck02ViewModel.BizPurpose) { var checkItem = quesMaster.QuesResult1.SingleOrDefault(m => m.QuestionSn == questionSn && m.CheckListSn == item.CheckListSn); if(checkItem == null) { var result1 = new QuesResult1(); result1.QuestionSn = questionSn; result1.CheckListSn = item.CheckListSn; result1.AnsVal = item.AnsVal; result1.RegDt = DateTime.Now; result1.RegId = Session[Global.LoginID].ToString(); quesMaster.QuesResult1.Add(result1); } else { checkItem.AnsVal = item.AnsVal; checkItem.UpdDt = DateTime.Now; checkItem.UpdId = Session[Global.LoginID].ToString(); } } foreach (var item in bizCheck02ViewModel.Leadership) { var checkItem = quesMaster.QuesResult1.SingleOrDefault(m => m.QuestionSn == questionSn && m.CheckListSn == item.CheckListSn); if (checkItem == null) { var result1 = new QuesResult1(); result1.QuestionSn = questionSn; result1.CheckListSn = item.CheckListSn; result1.AnsVal = item.AnsVal; result1.RegDt = DateTime.Now; result1.RegId = Session[Global.LoginID].ToString(); quesMaster.QuesResult1.Add(result1); } else { checkItem.AnsVal = item.AnsVal; checkItem.UpdDt = DateTime.Now; checkItem.UpdId = Session[Global.LoginID].ToString(); } } await _quesMasterService.SaveDbContextAsync(); } else { //에러처리 필요 return View(bizCheck02ViewModel); } if (bizCheck02ViewModel.SubmitType == "T") { return RedirectToAction("BizCheck02", "Report", new { @questionSn = questionSn }); } else { return RedirectToAction("BizCheck03", "Report", new { @questionSn = questionSn }); } }
public async Task<ActionResult> BizCheck02(string questionSn, string status) { ViewBag.LeftMenu = Global.Report; if (string.IsNullOrEmpty(questionSn)) { // 오류 처리해야함. return View(); } var bizCheck02 = new BizCheck02ViewModel(); // A1A101 : 경영목표 및 전략 코드 var quesResult1sPurpose = await _quesResult1Service.GetQuesResult1sAsync(int.Parse(questionSn), "A1A101"); if (quesResult1sPurpose.Count() != 5) { var quesCheckList = await _quesCheckListService.GetQuesCheckListAsync("A1A101"); var quesCheckListView = Mapper.Map<List<QuesCheckListViewModel>>(quesCheckList); foreach (var item in quesCheckListView) { item.QuestionSn = int.Parse(questionSn); item.AnsVal = false; } bizCheck02.BizPurpose = quesCheckListView; } else { var quesCheckListView = Mapper.Map<List<QuesCheckListViewModel>>(quesResult1sPurpose); bizCheck02.BizPurpose = quesCheckListView; } // A1A102 : 경영자의 리더쉽 코드 var quesResult1sLeadership = await _quesResult1Service.GetQuesResult1sAsync(int.Parse(questionSn), "A1A102"); if (quesResult1sLeadership.Count() != 5) { var quesCheckList = await _quesCheckListService.GetQuesCheckListAsync("A1A102"); var quesCheckListView = Mapper.Map<List<QuesCheckListViewModel>>(quesCheckList); foreach (var item in quesCheckListView) { item.QuestionSn = int.Parse(questionSn); item.AnsVal = false; } bizCheck02.Leadership = quesCheckListView; } else { var quesCheckListView = Mapper.Map<List<QuesCheckListViewModel>>(quesResult1sLeadership); bizCheck02.Leadership = quesCheckListView; } bizCheck02.Status = status; bizCheck02.QuestionSn = int.Parse(questionSn); return View(bizCheck02); }