Exemplo n.º 1
0
        public bool DeleteImageById(int id)
        {
            try
            {
                bool result = false;

                var img = GetImagesById(id);

                if (id > 0)
                {
                    //try delete first
                    string svrImagesPath = ConfigurationHelper.ImagesDirectory();
                    result = Helpers.DirectoryHelper.DeleteFile(svrImagesPath, img.ImageName) == "File Deleted";

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


                    IContentRepository repos = new ContentRepository();
                    result = repos.DeleteImage(id);
                    Helpers.CacheHelper.RemoveObjectFromCache(Helpers.CacheHelperKeys.CK_ALL_PAGES);
                }


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