public JsonResult Edit(FormCollection collection, string[] FOLDER_ID, string[] filename, IEnumerable <HttpPostedFileBase> filebase) { DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); var result = new JsonResultBO(true); AssignUserInfo(); try { var id = collection["ID"].ToIntOrZero(); var myobj = DM_DANHMUC_DATABusiness.Find(id); myobj.DATA = collection["DATA"].ToIntOrZero(); myobj.TEXT = collection["TEXT"].ToString(); myobj.CODE = collection["CODE"]; myobj.GHICHU = collection["GHICHU"].ToString(); myobj.COLOR = collection["COLOR"].ToString(); myobj.DEPTID = collection["DEPTID"].ToIntOrNULL(); if (filebase != null && filebase.FirstOrDefault() != null) { FileUltilities file = new FileUltilities(); TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>(); List <TAILIEUDINHKEM> ListTaiLieu = TAILIEUDINHKEMBusiness.GetDataByItemID(myobj.ID, LOAITAILIEU.MST_DIVISION); foreach (var item in ListTaiLieu) { file.RemoveFile(UPLOADFOLDER + "/" + item.DUONGDAN_FILE); TAILIEUDINHKEMBusiness.repository.Delete(item.TAILIEU_ID); } TAILIEUDINHKEMBusiness.Save(); if (filename == null) { filename = new string[filebase.Count()]; } UploadFileTool tool = new UploadFileTool(); List <string> FileName = new List <string>(); List <string> FilePath = new List <string>(); List <long> FileId = new List <long>(); tool.UploadCustomFileAndOutPath(filebase, false, MstDivisionExtension, UPLOADFOLDER, int.Parse(MstDivisionSize), FOLDER_ID, filename, myobj.ID, out FilePath, out FileName, out FileName, out FileId, LOAITAILIEU.MST_DIVISION, "Danh mục dùng chung"); if (FilePath.Any()) { myobj.ICON = FilePath[0]; } } DM_DANHMUC_DATABusiness.Save(myobj); } catch (Exception ex) { result.Status = false; result.Message = "Không cập nhật được"; } return(Json(result)); }
public JsonResult Create(FormCollection collection, string[] FOLDER_ID, string[] filename, IEnumerable <HttpPostedFileBase> filebase) { DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); var result = new JsonResultBO(true); try { var myobj = new DM_DANHMUC_DATA(); myobj.DM_NHOM_ID = collection["DM_NHOM_ID"].ToIntOrZero(); myobj.DATA = collection["DATA"].ToIntOrZero(); myobj.TEXT = collection["TEXT"].ToString(); myobj.CODE = collection["CODE"]; myobj.COLOR = collection["COLOR"].ToString(); myobj.GHICHU = collection["GHICHU"].ToString(); myobj.DEPTID = collection["DEPTID"].ToIntOrNULL(); DM_DANHMUC_DATABusiness.Save(myobj); if (filebase != null) { if (filename == null) { filename = new string[filebase.Count()]; } UploadFileTool tool = new UploadFileTool(); List <string> FileName = new List <string>(); List <string> FilePath = new List <string>(); List <long> FileId = new List <long>(); tool.UploadCustomFileAndOutPath(filebase, false, MstDivisionExtension, UPLOADFOLDER, int.Parse(MstDivisionSize), FOLDER_ID, filename, myobj.ID, out FilePath, out FileName, out FileName, out FileId, LOAITAILIEU.MST_DIVISION, "Danh mục dùng chung"); if (FilePath.Any()) { myobj.ICON = FilePath[0]; DM_DANHMUC_DATABusiness.Save(myobj); } } } catch (Exception ex) { result.Status = false; result.Message = "Không thêm mới được"; } return(Json(result)); }