public IObservable<System.Reactive.Unit> DeleteFile(string owner, string name, string path, DeleteFileRequest request)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(path, "path");
            Ensure.ArgumentNotNull(request, "request");

            return _client.Repository.Content.DeleteFile(owner, name, path, request).ToObservable();
        }
Example #2
0
        /// <summary>
        /// Deletes the specified file.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>DeleteFileResponse</c> with success status.
        /// </returns>
        public DeleteFileResponse Delete(DeleteFileRequest request)
        {
            if (request.Data == null || request.Id.HasDefaultValue())
            {
                return new DeleteFileResponse { Data = false };
            }

            var result = mediaService.DeleteMedia(request.Id, request.Data.Version, false);

            return new DeleteFileResponse { Data = result };
        }
Example #3
0
        /// <summary>
        /// Deletes the specified file.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>DeleteFileResponse</c> with success status.
        /// </returns>
        public DeleteFileResponse Delete(DeleteFileRequest request)
        {
            if (request.Data == null || request.Id.HasDefaultValue())
            {
                return new DeleteFileResponse { Data = false };
            }

            var itemToDelete = repository
                .AsQueryable<MediaFile>()
                .Where(p => p.Id == request.Id)
                .FirstOne();

            if (request.Data.Version > 0 && itemToDelete.Version != request.Data.Version)
            {
                throw new ConcurrentDataException(itemToDelete);
            }

            unitOfWork.BeginTransaction();

            mediaService.DeleteMedia(itemToDelete);

            unitOfWork.Commit();

            Events.MediaManagerEvents.Instance.OnMediaFileDeleted(itemToDelete);

            return new DeleteFileResponse { Data = true };
        }
        /// <summary>
        /// Creates a commit that deletes a file in a repository.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="path">The path to the file</param>
        /// <param name="request">Information about the file to delete</param>
        public IObservable<Unit> DeleteFile(int repositoryId, string path, DeleteFileRequest request)
        {
            Ensure.ArgumentNotNullOrEmptyString(path, "path");
            Ensure.ArgumentNotNull(request, "request");

            return _client.Repository.Content.DeleteFile(repositoryId, path, request).ToObservable();
        }