コード例 #1
0
        public async Task<ActionResult> ModifyMyInfo(JoinExpertViewModel joinExpertViewModel, string DeleteFileSn, IEnumerable<HttpPostedFileBase> files)
        {
            ViewBag.LeftMenu = Global.MyInfo;
            var scExpertMapping = await _scExpertMappingService.GetExpertAsync(Session[Global.LoginID].ToString());

            scExpertMapping.ScUsr.UsrTypeDetail = joinExpertViewModel.UsrTypeDetail;
            scExpertMapping.ScUsr.Name = joinExpertViewModel.Name;
            scExpertMapping.ScUsr.TelNo = joinExpertViewModel.TelNo1+"-"+ joinExpertViewModel.TelNo2 + "-" + joinExpertViewModel.TelNo3;
            scExpertMapping.ScUsr.MbNo = joinExpertViewModel.MbNo1 + "-" + joinExpertViewModel.MbNo2 + "-" + joinExpertViewModel.MbNo3;
            scExpertMapping.ScUsr.Email = joinExpertViewModel.Email1 + "@" + joinExpertViewModel.Email2;

            scExpertMapping.ScUsr.ScCompInfo.CompNm = joinExpertViewModel.CompNm;
            scExpertMapping.ScUsr.ScCompInfo.OwnNm = joinExpertViewModel.ComOwnNm;
            scExpertMapping.ScUsr.ScCompInfo.RegistrationNo = joinExpertViewModel.ComRegistrationNo;
            scExpertMapping.ScUsr.ScCompInfo.TelNo = joinExpertViewModel.ComTelNo1 + "-" + joinExpertViewModel.ComTelNo2 + "-" + joinExpertViewModel.ComTelNo3;
            scExpertMapping.ScUsr.ScCompInfo.PostNo = joinExpertViewModel.ComPostNo;
            scExpertMapping.ScUsr.ScCompInfo.Addr1 = joinExpertViewModel.ComAddr1;
            scExpertMapping.ScUsr.ScCompInfo.Addr2 = joinExpertViewModel.ComAddr2;

            //업종 , 종목
            int compSn = int.Parse(Session[Global.CompSN].ToString());
            if (joinExpertViewModel.BizTypes.Count > 0)
            {
                _scBizTypeService.DeleteScBizTypeByCompSn(compSn);

                foreach (var item in joinExpertViewModel.BizTypes)
                {
                    var scBizType = new ScBizType
                    {
                        CompSn = compSn,
                        BizTypeCd = item.BizTypeCd,
                        BizTypeNm = item.BizTypeNm
                    };

                    _scBizTypeService.AddScBizType(scBizType);
                }
            }

            //파일정보 업데이트
            if (!string.IsNullOrEmpty(DeleteFileSn))
            {
                scExpertMapping.ScUsr.ScUsrResume.ScFileInfo.Status = "D";
            }

            //신규파일정보저장 및 파일업로드
            foreach (var file in files)
            {
                if (file != null)
                {
                    var fileHelper = new FileHelper();

                    var savedFileName = fileHelper.GetUploadFileName(file);

                    var subDirectoryPath = Path.Combine(FileType.Resume.ToString(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString());

                    var savedFilePath = Path.Combine(subDirectoryPath, savedFileName);

                    var scFileInfo = new ScFileInfo { FileNm = Path.GetFileName(file.FileName), FilePath = savedFilePath, Status = "N", RegId = Session[Global.LoginID].ToString(), RegDt = DateTime.Now };
                    var scUsrResume = new ScUsrResume { ScFileInfo = scFileInfo };
                    scExpertMapping.ScUsr.ScUsrResume = scUsrResume;

                    await fileHelper.UploadFile(file, subDirectoryPath, savedFileName);
                }
            }

            int result = await _scExpertMappingService.SaveDbContextAsync();

            if (result != -1)
                return RedirectToAction("MyInfo", "Main");
            else
            {
                ModelState.AddModelError("", "내정보 수정 실패.");

                var usrView =
                   Mapper.Map<JoinExpertViewModel>(scExpertMapping);

                return View(usrView);
            }
        }
コード例 #2
0
        public async Task<ActionResult> ModifyMyInfo(MentorMyInfoViewModel mentorViewModel, ModifyMentorParamModel param, IEnumerable<HttpPostedFileBase> files)
        {
            ViewBag.LeftMenu = Global.MyInfo;

            ScUsr scUsr = await _scUsrService.SelectMentorInfo(Session[Global.LoginID].ToString());

            if (Session[Global.LoginID].ToString() != param.LoginIdChk)
            {
                mentorViewModel =
                   Mapper.Map<MentorMyInfoViewModel>(scUsr);
                ModelState.AddModelError("", "로그인된 아이디가 아닙니다.");
                return View(mentorViewModel);
            }

            //실제패스워드와 입력패스워드 비교
            SHACryptography sha2 = new SHACryptography();
            if (param.LoginPwChk != sha2.EncryptString(mentorViewModel.LoginPw))
            {
                mentorViewModel =
                   Mapper.Map<MentorMyInfoViewModel>(scUsr);

                ModelState.AddModelError("", "비밀번호가 일치하지 않습니다.");
                return View(mentorViewModel);
            }

            scUsr.AccountNo = mentorViewModel.AccountNo;
            scUsr.Addr1 = mentorViewModel.Addr1;
            scUsr.Addr2 = mentorViewModel.Addr2;
            scUsr.BankNm = mentorViewModel.BankNm;
            scUsr.Email = mentorViewModel.Email1 + "@" + mentorViewModel.Email2;
            scUsr.FaxNo = mentorViewModel.FaxNo1 + "-" + mentorViewModel.FaxNo2 + "-" + mentorViewModel.FaxNo3;
            scUsr.MbNo = mentorViewModel.MbNo1 + "-" + mentorViewModel.MbNo2 + "-" + mentorViewModel.MbNo3;
            scUsr.Name = mentorViewModel.Name;
            scUsr.PostNo = mentorViewModel.PostNo;
            scUsr.TelNo = mentorViewModel.TelNo1 + "-" + mentorViewModel.TelNo2 + "-" + mentorViewModel.TelNo3;
            scUsr.UsrTypeDetail = mentorViewModel.UsrTypeDetail;

            //_scUsrService.ModifyScUsr(scUsr);

            //파일정보 업데이트
            if (!string.IsNullOrEmpty(param.DeleteFileSn))
            {
                scUsr.ScUsrResume.ScFileInfo.Status = "D";
            }

            //신규파일정보저장 및 파일업로드
            foreach (var file in files)
            {
                if(file !=null)
                {
                    var fileHelper = new FileHelper();

                    var savedFileName = fileHelper.GetUploadFileName(file);

                    var subDirectoryPath = Path.Combine(FileType.Resume.ToString(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString());

                    var savedFilePath = Path.Combine(subDirectoryPath, savedFileName);

                    var scFileInfo = new ScFileInfo { FileNm = Path.GetFileName(file.FileName), FilePath = savedFilePath, Status = "N", RegId = param.LoginIdChk, RegDt = DateTime.Now };
                    var scUsrResume = new ScUsrResume { ScFileInfo = scFileInfo };
                    scUsr.ScUsrResume = scUsrResume;

                    //_scUsrService.ModifyMentorInfo(scUsr);

                    await fileHelper.UploadFile(file, subDirectoryPath, savedFileName);
                }
            }

            _scUsrService.ModifyScUsr(scUsr);

            //다성공시 커밋
            await _scUsrService.SaveDbContextAsync();

            return RedirectToAction("MyInfo", "Main");
        }