Пример #1
0
        public JsonResult Delete(long id)
        {
            HSCV_VANBANDENBusiness = Get <HSCV_VANBANDENBusiness>();
            HSCV_VANBANDEN VanBan = HSCV_VANBANDENBusiness.Find(id);

            AssignUserInfo();
            if (VanBan == null || currentUser.ID != VanBan.NGUOITAO)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy văn bản phát hành cần xóa" }));
            }
            TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>();
            FileUltilities        file        = new FileUltilities();
            List <TAILIEUDINHKEM> ListTaiLieu = TAILIEUDINHKEMBusiness.GetDataByItemID(id, LOAITAILIEU.VANBANDEN);

            foreach (var item in ListTaiLieu)
            {
                TAILIEUDINHKEMBusiness.repository.Delete(item.TAILIEU_ID);
                file.RemoveFile(URL_FOLDER + item.DUONGDAN_FILE);
                if (!string.IsNullOrEmpty(item.PDF_VERSION))
                {
                    file.RemoveFile(URL_FOLDER + item.PDF_VERSION);
                }
            }
            THUMUC_LUUTRUBusiness = Get <THUMUC_LUUTRUBusiness>();
            THUMUC_LUUTRU ThuMuc = THUMUC_LUUTRUBusiness.GetDataByNam(id.ToString(), ThuMucLuuTruConstant.DefaultVbDen);

            if (ThuMuc != null)
            {
                ThuMuc.IS_DELETE = true;
                THUMUC_LUUTRUBusiness.Save(ThuMuc);
            }
            TAILIEUDINHKEMBusiness.Save();
            HSCV_VANBANDENBusiness.repository.Delete(id);
            HSCV_VANBANDENBusiness.Save();
            #region Xóa đơn vị nhận văn bản
            HSCV_VANBANDEN_DONVINHANBusiness = Get <HSCV_VANBANDEN_DONVINHANBusiness>();
            var ListDonVi = HSCV_VANBANDEN_DONVINHANBusiness.GetData(id);
            if (ListDonVi.Any())
            {
                foreach (var item in ListDonVi)
                {
                    HSCV_VANBANDEN_DONVINHANBusiness.repository.Delete(item.ID);
                }
                HSCV_VANBANDEN_DONVINHANBusiness.Save();
            }
            #endregion
            return(Json(new { Type = "SUCCESS", Message = "Xóa văn bản phát hành thành công" }));
        }
        public JsonResult Delete(long id)
        {
            hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>();
            HSCV_VANBANDEN entityVanBanDen = hscvVanBanDenBusiness.Find(id);

            AssignUserInfo();
            if (entityVanBanDen == null || currentUser.ID != entityVanBanDen.NGUOITAO)
            {
                return(Json(new { Type = "ERROR", Message = "Bạn không có quyền xóa văn bản trình ký này" }));
            }
            attachmentBusiness = Get <TAILIEUDINHKEMBusiness>();
            FileUltilities        file        = new FileUltilities();
            List <TAILIEUDINHKEM> ListTaiLieu = attachmentBusiness.GetDataByItemID(id, LOAITAILIEU.VANBANDEN);

            foreach (var item in ListTaiLieu)
            {
                attachmentBusiness.repository.Delete(item.TAILIEU_ID);
                file.RemoveFile(uploadFolder + item.DUONGDAN_FILE);
                if (!string.IsNullOrEmpty(item.PDF_VERSION))
                {
                    file.RemoveFile(uploadFolder + item.PDF_VERSION);
                }
            }
            storeFolderBusiness = Get <THUMUC_LUUTRUBusiness>();
            THUMUC_LUUTRU ThuMuc = storeFolderBusiness.GetDataByNam(id.ToString(), ThuMucLuuTruConstant.DefaultVanban);

            if (ThuMuc != null)
            {
                ThuMuc.IS_DELETE = true;
                storeFolderBusiness.Save(ThuMuc);
            }
            attachmentBusiness.Save();
            hscvVanBanDenBusiness.repository.Delete(id);
            #region xóa văn bản đến trong elastic

            ElasticSearch.deleteDocument(id.ToString(), ElasticType.VanBanDen);
            #endregion
            return(Json(new { Type = "SUCCESS", Message = "Xóa văn bản đến thành công" }));
        }