Blog.Logic.Core.MediaLogic.Delete C# (CSharp) Method

Delete() public method

public Delete ( int mediaId ) : bool
mediaId int
return bool
        public bool Delete(int mediaId)
        {
            try
            {
                var db = _mediaRepository.Find(a => a.MediaId == mediaId, false).FirstOrDefault();
                if (db == null) return false;

                // TODO: Removed for now as it causes privilege issues
                //_fileHelper.DeleteFile(db.ThumbnailPath);
                //_fileHelper.DeleteFile(db.MediaPath);
                //_fileHelper.DeleteDirectory(db.ThumbnailPath);
                //_fileHelper.DeleteDirectory(db.MediaPath);
                _mediaRepository.Delete(db);

                return true;
            }
            catch (Exception ex)
            {
                throw new BlogException(ex.Message, ex.InnerException);
            }
        }