Esempio n. 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);
            }
        }
        public async Task<ActionResult> RegExpertManager(JoinExpertViewModel joinExpertViewModel, string BizList)
        {
            ViewBag.LeftMenu = Global.ExpertMng;

            var bizMngList = await _scUsrService.GetBizManagerAsync();
            var bizMngDropDown =
                Mapper.Map<List<BizMngDropDownModel>>(bizMngList);
            BizMngDropDownModel title = new BizMngDropDownModel();
            title.CompSn = 0;
            title.CompNm = "사업관리기관 선택";
            bizMngDropDown.Insert(0, title);
            
            SelectList bizList = new SelectList(bizMngDropDown, "CompSn", "CompNm");
            ViewBag.SelectBizMngList = bizList;

            if (ModelState.IsValid)
            {
                if(string.IsNullOrEmpty(BizList) || BizList == "0" )
                {
                    ModelState.AddModelError("", "사업명을 선택하지 않았습니다.");
                    return View(joinExpertViewModel);
                }

                var expert = await _scExpertMappingService.GetSameDetailTypeExpertAsync(int.Parse(BizList), joinExpertViewModel.UsrTypeDetail);
                if(expert != null)
                {
                    ModelState.AddModelError("", "동일한 분야의 전문가가 이미 사업에 맵핑되어 있습니다.");
                    return View(joinExpertViewModel);
                }

                var scUsr = Mapper.Map<ScUsr>(joinExpertViewModel);
                var scCompInfo = Mapper.Map<ScCompInfo>(joinExpertViewModel);

                //회원정보 추가 정보 설정
                scUsr.RegId = Session[Global.LoginID].ToString();
                scUsr.RegDt = DateTime.Now;
                scUsr.Status = "N";
                scUsr.UsrType = "P";

                SHACryptography sha2 = new SHACryptography();
                scUsr.LoginPw = sha2.EncryptString(scUsr.LoginPw);

                //회사정보 추가 정보 설정
                scCompInfo.Status = "N";
                scCompInfo.RegId = Session[Global.LoginID].ToString();
                scCompInfo.RegDt = DateTime.Now;

                //전문가 매핑정보 생성
                IList<ScExpertMapping> scExpertMappings = new List<ScExpertMapping>();
                ScExpertMapping scExpertMapping = new ScExpertMapping();
                scExpertMapping.BizWorkSn = int.Parse(BizList);
                scExpertMapping.ExpertId = scUsr.LoginId;
                scExpertMapping.Status = "N";
                scExpertMapping.RegId = scUsr.RegId;
                scExpertMapping.RegDt = scUsr.RegDt;
                scExpertMappings.Add(scExpertMapping);
                scUsr.ScExpertMappings = scExpertMappings;

                //저장
                IList<ScUsr> scUsrs = new List<ScUsr>();
                scUsrs.Add(scUsr);
                scCompInfo.ScUsrs = scUsrs;


                //bool result = _scUsrService.AddCompanyUser(scCompInfo, scUsr, syUser);
                int result = await _scUsrService.AddBizManagerAsync(scCompInfo);

                if (result != -1)
                    return RedirectToAction("ExpertManager", "ExpertManager");
                else
                { 
                    ModelState.AddModelError("", "전문가 등록 실패.");
                    return View(joinExpertViewModel);
                }
            }
            return View(joinExpertViewModel);
        }