public JsonResult SetBoardContents(BbsContentsModel bbsContents) { try { bool isNew = bbsContents.bbs_idx == null ? true : false; if (isNew) { bbsContents.create_us = Convert.ToInt32(Session["USER_IDX"]); int bbsIDX = (int)Mapper.Instance().Insert("Bbs.insBbsContent", bbsContents); return(Json(bbsIDX)); } else { Mapper.Instance().Update("Bbs.udtBbsContent", bbsContents); //var bbsIDX = (int)Mapper.Instance().Update("Bbs.udtBbsContent", bbsContents.bbs_idx); return(Json(bbsContents)); // return Json(bbsIDX); } } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() }));; } }
{ //view는 그냥 이름으로 해주고 기능은 select = get 나머지 =set 붙여주기 public ActionResult BoardWrite(BbsContentsModel bbsContents) { var getBbsCategory = Mapper.Instance().QueryForList <CommLibraryModel>("Common.selCommCode", new CommLibraryModel { parent_code = "Category", use_fl = "Y" }); ViewBag.BbsCategory = getBbsCategory; return(View()); }
//view단 //grid밑단 list Data뿌리기 public ActionResult getBoardList(BbsContentsModel BbsContentsModel)//콜백함수 { try { return(Json(Mapper.Instance().QueryForList <BbsContentsModel>("Bbs.selBbsContent", BbsContentsModel)));//xml.id값 } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
/* * //파일 insert * public JsonResult setBbsFile(BbsFileModel bbsFile) * { * try * { * int bbsIDX = (int)Mapper.Instance().Insert("Bbs.insBbsFile", bbsFile); * return Json(bbsIDX); * } * catch(Exception ex) * { * return Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() }); * } * } */ public JsonResult setBoardWrite(BbsContentsModel bbsContents) { try { //섹션에 있는 idx값 가져와 강제넣 bbsContents.create_us = Convert.ToInt32(Session["USER_IDX"]); int bbsIDX = (int)Mapper.Instance().Insert("Bbs.insBbsContent", bbsContents);//xml return(Json(bbsIDX)); } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
{ //view는 그냥 이름으로 해주고 기능은 select = get 나머지 =set 붙여주기 public ActionResult BoardWrite(BbsContentsModel bbsContents) { return(View()); }
public JsonResult SetBoardContents() { try { FormCollection collection = new FormCollection(Request.Unvalidated.Form); BbsContentsModel bbsContents = new BbsContentsModel(); bbsContents.bbs_idx = collection["bbs_idx"] == null ? null : (int?)Convert.ToInt32(collection["bbs_idx"].Split(',')[1]); bbsContents.bbs_title = collection["bbs_title"] == null ? "" : collection["bbs_title"].Trim() == "" ? "" : collection["bbs_title"].Split(',')[1]; bbsContents.bbs_content = collection["bbs_content"] == null ? "" : collection["bbs_content"].Trim() == "" ? "" : collection["bbs_content"].Split(',')[1]; bool isNew = bbsContents.bbs_idx == null ? true : false; if (isNew)//신규작성 { Mapper.Instance().BeginTransaction(); bbsContents.create_us = Convert.ToInt32(Session["USER_IDX"]); bbsContents.bbs_category = collection["bbs_category"] == null ? "" : collection["bbs_category"].Trim() == "" ? "" : collection["bbs_category"].Split(',')[1]; int bbs_idx = (int)Mapper.Instance().Insert("Bbs.insBbsContent", bbsContents); foreach (string f in Request.Files) { //xhr에 있. HttpPostedFileBase file = Request.Files[f]; //파일명으로 찾아서 serlec BbsFileModel BbsFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbs_idx, file_org_nm = file.FileName }); string fileOrgName = file.FileName; string fileExtension = Path.GetExtension(file.FileName); //확장자 string fileName = Path.GetFileNameWithoutExtension(file.FileName); //without확장자 string fileConvNm = AESEncrypt.AESEncrypt256(fileName, bbs_idx.ToString()); string valutPath = System.Configuration.ConfigurationManager.AppSettings["BbsFilePath"].ToString(); int?BbsFIleIdx = (int)Mapper.Instance().Insert("Bbs.insBbsFile", new BbsFileModel { bbs_idx = bbs_idx, file_org_nm = file.FileName, file_conv_nm = fileConvNm + fileExtension }); CommonUtil.FileSave(valutPath + "\\" + bbs_idx, file, fileConvNm + fileExtension);//\은 두개써야함 인식못함. } Mapper.Instance().CommitTransaction(); return(Json(bbsContents)); } else//수정 { Mapper.Instance().BeginTransaction(); bbsContents.bbs_category = collection["bbs_category"] == null ? "" : collection["bbs_category"].Trim() == "" ? "" : collection["bbs_category"].Split(',')[1]; Mapper.Instance().Update("Bbs.udtBbsContent", new BbsContentsModel { bbs_idx = bbsContents.bbs_idx, bbs_category = bbsContents.bbs_category, bbs_title = bbsContents.bbs_title, bbs_content = bbsContents.bbs_content }); var bbsPrevFileList = Mapper.Instance().QueryForList <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel { bbs_idx = bbsContents.bbs_idx }); int prevFileCount = bbsPrevFileList.Count(); foreach (string f in Request.Files) { HttpPostedFileBase file = Request.Files[f]; // 기존에 등록되있으면서 삭제되지 않을 파일 if (file.ContentLength == 0) { continue; } // Insert BbsFileModel BbsFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbsContents.bbs_idx, file_org_nm = file.FileName }); string fileOrgName = file.FileName; string fileExtension = Path.GetExtension(file.FileName); //확장자 string fileName = Path.GetFileNameWithoutExtension(file.FileName); //without확장자 string fileConvNm = AESEncrypt.AESEncrypt256(fileName, bbsContents.bbs_idx.ToString()); string valutPath = System.Configuration.ConfigurationManager.AppSettings["BbsFilePath"].ToString(); int?BbsFIleIdx = (int)Mapper.Instance().Insert("Bbs.insBbsFile", new BbsFileModel { bbs_idx = bbsContents.bbs_idx, file_org_nm = file.FileName, file_conv_nm = fileConvNm + fileExtension }); CommonUtil.FileSave(valutPath + "\\" + bbsContents.bbs_idx, file, fileConvNm + fileExtension);//\은 두개써야함 인식못함. } for (int iCnt = 0; iCnt < prevFileCount; iCnt++) { bool isExist = false; foreach (string f in Request.Files) { if (bbsPrevFileList[iCnt].file_org_nm == Request.Files[f].FileName) { isExist = true; break; } } if (!isExist) { //DELETE //bbsPrevFileList[iCnt]; BbsFileModel BbsDelFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbsContents.bbs_idx, file_org_nm = bbsPrevFileList[iCnt].file_org_nm }); var fileIDX = BbsDelFIleList.bbs_file_idx; var bbsIDX = BbsDelFIleList.bbs_idx; setFileDelete(fileIDX); } } Mapper.Instance().CommitTransaction(); return(Json(bbsContents.bbs_idx)); } }//try catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }