Exemplo n.º 1
0
        public bool DeletePdfById(int id)
        {
            try
            {
                bool result = false;
                IContentRepository repos = new ContentRepository();

                var pdf = repos.FetchPdfById(id);

                if (pdf.PdfId > 0)
                {
                    //to do
                    // delete the reference with all objects...update set null...
                    //try delete first
                    string svrPdfPath = ConfigurationHelper.PdfDirectory();
                    result = Helpers.DirectoryHelper.DeleteFile(svrPdfPath, pdf.PdfGuid) == "File Deleted";

                    if (!result)
                    {
                        log.WarnFormat("Pdf {0} could not be deleted from server as it was not found ", pdf.PdfGuid);
                    }
                    //if ok - delete in db


                    result = repos.DeletePdf(id);
                    //Helpers.CacheHelper.RemoveObjectFromCache(Helpers.CacheHelperKeys.CK_ALL_PAGES);
                }


                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }