public async Task <ActionResult> RegMentoringReport(MentoringReportViewModel dataRequestViewModel, IEnumerable <HttpPostedFileBase> files) { ViewBag.naviLeftMenu = Global.MentoringReport; var mentorId = Session[Global.LoginID].ToString(); SqlParameter loginId = new SqlParameter("LOGIN_ID", Session[Global.LoginID]); // sql 파라미터 값 설정 object[] parameters = new object[] { loginId }; // 객체에 데이터 삽입 var obj = await procMngService.getCompMapping(parameters); // 해당 기업과 관련된 리스트데이터 가져오기 var usrViews = Mapper.Map <List <MentoringReportViewModel> >(obj); //if (ModelState.IsValid) //{ var scMentoringReport = Mapper.Map <ScMentoringReport>(dataRequestViewModel); //var comp = usrViews[0].CompSn; scMentoringReport.MentorId = mentorId; scMentoringReport.RegId = mentorId; scMentoringReport.RegDt = DateTime.Now; scMentoringReport.Status = "N"; scMentoringReport.CompSn = scMentoringReport.CompSn; var compInfo = await _vcCompInfoService.getVcCompInfoByCompSn(scMentoringReport.CompSn ?? default(int)); // ConCode, NumSn, SubNumSn 자동 할당 // MentorId로 해당 기업의 num_sn, sub_num_sn을 가져온다 SqlParameter compSn2 = new SqlParameter("COMP_SN", scMentoringReport.CompSn); SqlParameter loginId2 = new SqlParameter("LOGIN_ID", Session[Global.LoginID].ToString()); object[] parameters2 = new object[] { compSn2, loginId2 }; var compList = await procMngService.getMentorCompNumSn(parameters2); var mentorLoginKey = Session[Global.LoginID].ToString(); var mentorInfo = await _vcUsrService.getMentorInfoById(mentorLoginKey); var baSn = mentorInfo.BaSn; //var conCodeInfo = await _vcMentorMappingService.getConcodeInfo(dataRequestViewModel.CompSn, baSn, mentorInfo.MentorSn, compList[0].NUM_SN, compList[0].SUB_NUM_SN); scMentoringReport.NumSn = compList[0].NUM_SN; scMentoringReport.SubNumSn = compList[0].SUB_NUM_SN; scMentoringReport.ConCode = compList[0].CON_CODE; //첨부파일 if (files != null) { var fileHelper = new FileHelper(); foreach (var file in files) { if (file != null) { //var compSn = usrViews[cnt].CompSn; var savedFileName = fileHelper.GetUploadFileName(file); var subDirectoryPath = Path.Combine(FileType.Mentoring_Report.ToString(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString()); var savedFilePath = Path.Combine(subDirectoryPath, savedFileName); var tcmsLoginKey = Session[Global.LoginID].ToString(); var tcmsLoginKeyCon = int.Parse(tcmsLoginKey); var mentorUsrInfo = await _vcUsrService.getUsrInfoByTcmsKey(tcmsLoginKeyCon); var mentorIdInfo = mentorUsrInfo.LoginId; var scFileInfo = new ScFileInfo { FileNm = Path.GetFileName(file.FileName), FilePath = savedFilePath, Status = "N", RegId = mentorIdInfo, RegDt = DateTime.Now }; var scMentoringFileInfo = new ScMentoringFileInfo { ScFileInfo = scFileInfo }; //파일타입에 따라 재정의해서 넣어야 함(첨부파일, 사진) scMentoringFileInfo.Classify = fileHelper.HasImageFile(file) ? "P" : "A"; scMentoringReport.RegId = mentorIdInfo; scMentoringReport.MentorId = mentorIdInfo; scMentoringReport.ScMentoringFileInfoes.Add(scMentoringFileInfo); await fileHelper.UploadFile(file, subDirectoryPath, savedFileName); } } } //저장 int result = await _scMentoringReportService.AddScMentoringReportAsync(scMentoringReport); if (result != -1) { return(RedirectToAction("MentoringReportList", "MentoringReport")); } else { ModelState.AddModelError("", "자료요청 등록 실패."); return(View(dataRequestViewModel)); } // } //ModelState.AddModelError("", "입력값 검증 실패."); //return View(dataRequestViewModel); }