public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var options = request.Options; var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, DeleteOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } var deleteSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _publisher.Publish(new UserManagementMessage.Delete(envelope, user, options.LoginName)); await deleteSource.Task.ConfigureAwait(false); return(new DeleteResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, deleteSource)) { return; } deleteSource.TrySetResult(true); } }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var options = request.Options; var streamName = options.StreamName; var expectedVersion = options.ExpectedStreamRevisionCase switch { DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.Revision => new StreamRevision(options.Revision).ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.Any => AnyStreamRevision.Any.ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.NoStream => AnyStreamRevision.NoStream.ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.StreamExists => AnyStreamRevision.StreamExists.ToInt64(), _ => throw new InvalidOperationException() }; var user = context.GetHttpContext().User; var requiresLeader = GetRequiresLeader(context.RequestHeaders); var position = await DeleteInternal(streamName, expectedVersion, user, false, requiresLeader).ConfigureAwait(false); return(position.HasValue ? new DeleteResp { Position = new DeleteResp.Types.Position { CommitPosition = position.Value.CommitPosition, PreparePosition = position.Value.PreparePosition } } : new DeleteResp { NoPosition = new Empty() }); }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var options = request.Options; var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); var deleteSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish(new UserManagementMessage.Delete(envelope, user, options.LoginName)); await deleteSource.Task.ConfigureAwait(false); return(new DeleteResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, deleteSource)) { return; } deleteSource.TrySetResult(true); } }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var deletedSource = new TaskCompletionSource <bool>(); var options = request.Options; var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); var name = options.Name; var deleteCheckpointStream = options.DeleteCheckpointStream; var deleteStateStream = options.DeleteStateStream; var deleteEmittedStreams = options.DeleteEmittedStreams; var runAs = new ProjectionManagementMessage.RunAs(user); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish(new ProjectionManagementMessage.Command.Delete(envelope, name, runAs, deleteCheckpointStream, deleteStateStream, deleteEmittedStreams)); await deletedSource.Task.ConfigureAwait(false); return(new DeleteResp()); void OnMessage(Message message) { if (!(message is ProjectionManagementMessage.Updated)) { deletedSource.TrySetException(UnknownMessage <ProjectionManagementMessage.Updated>(message)); return; } deletedSource.TrySetResult(true); } }
private async Task <DeleteResult> DeleteInternal(DeleteReq request, UserCredentials userCredentials, CancellationToken cancellationToken) { var result = await _client.DeleteAsync(request, RequestMetadata.Create(userCredentials), cancellationToken : cancellationToken); return(new DeleteResult(new Position(result.Position.CommitPosition, result.Position.PreparePosition))); }
private async Task <DeleteResult> DeleteInternal(DeleteReq request, EventStoreClientOperationOptions operationOptions, UserCredentials userCredentials, CancellationToken cancellationToken) { var result = await _client.DeleteAsync(request, RequestMetadata.Create(userCredentials), deadline : DeadLine.After(operationOptions.TimeoutAfter), cancellationToken); return(new DeleteResult(new Position(result.Position.CommitPosition, result.Position.PreparePosition))); }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <DeleteResp>(); var correlationId = Guid.NewGuid(); var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); _queue.Publish(new ClientMessage.DeletePersistentSubscription( correlationId, correlationId, new CallbackEnvelope(HandleDeletePersistentSubscriptionCompleted), request.Options.StreamName, request.Options.GroupName, user)); return(await createPersistentSubscriptionSource.Task.ConfigureAwait(false)); void HandleDeletePersistentSubscriptionCompleted(Message message) { if (message is ClientMessage.NotHandled notHandled && RpcExceptions.TryHandleNotHandled(notHandled, out var ex)) { createPersistentSubscriptionSource.TrySetException(ex); return; } if (!(message is ClientMessage.DeletePersistentSubscriptionCompleted completed)) { createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownMessage <ClientMessage.DeletePersistentSubscriptionCompleted>(message)); return; } switch (completed.Result) { case DeletePersistentSubscriptionResult.Success: createPersistentSubscriptionSource.TrySetResult(new DeleteResp()); return; case DeletePersistentSubscriptionResult.Fail: createPersistentSubscriptionSource.TrySetException(RpcExceptions.PersistentSubscriptionFailed(request.Options.StreamName, request.Options.GroupName, completed.Reason)); return; case DeletePersistentSubscriptionResult.DoesNotExist: createPersistentSubscriptionSource.TrySetException(RpcExceptions.PersistentSubscriptionDoesNotExist(request.Options.StreamName, request.Options.GroupName)); return; case DeletePersistentSubscriptionResult.AccessDenied: createPersistentSubscriptionSource.TrySetException(RpcExceptions.AccessDenied()); return; default: createPersistentSubscriptionSource.TrySetException(RpcExceptions.UnknownError(completed.Result)); return; } } }
private async Task <DeleteResult> DeleteInternal(DeleteReq request, EventStoreClientOperationOptions operationOptions, UserCredentials?userCredentials, CancellationToken cancellationToken) { _log.LogDebug("Deleting stream {streamName}.", request.Options.StreamName); var result = await _client.DeleteAsync(request, RequestMetadata.Create(userCredentials ?? Settings.DefaultCredentials), deadline : DeadLine.After(operationOptions.TimeoutAfter), cancellationToken); return(new DeleteResult(new Position(result.Position.CommitPosition, result.Position.PreparePosition))); }
private async Task <DeleteResult> DeleteInternal(DeleteReq request, EventStoreClientOperationOptions operationOptions, UserCredentials?userCredentials, CancellationToken cancellationToken) { _log.LogDebug("Deleting stream {streamName}.", request.Options.StreamIdentifier); var result = await _client.DeleteAsync(request, EventStoreCallOptions.Create(Settings, operationOptions, userCredentials, cancellationToken)); return(new DeleteResult(new Position(result.Position.CommitPosition, result.Position.PreparePosition))); }
public async Task <IActionResult> Delete([FromBody] DeleteReq req) { if (string.IsNullOrWhiteSpace(req.Key)) { this.NotFound("Method Dictionary/Delete params"); } Logger.LogInformation($"Delete dictionary key: {req.Key}"); await _service.Delete(req.Key).ConfigureAwait(false); return(Ok()); }
public async Task <IActionResult> Get([FromQuery] DeleteReq req) { if (string.IsNullOrWhiteSpace(req.Key)) { this.NotFound("Method Dictionary/Get params"); } Logger.LogInformation($"Delete dictionary key: {req.Key}"); var result = await _service.Get(req.Key).ConfigureAwait(false); if (result == null) { return(NotFound($"Dictionary key not exist: {req.Key}")); } return(Ok(result)); }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var options = request.Options; var streamName = options.StreamName; var expectedVersion = options.ExpectedStreamRevisionCase switch { DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.Revision => new StreamRevision(options.Revision).ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.Any => AnyStreamRevision.Any.ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.NoStream => AnyStreamRevision.NoStream.ToInt64(), DeleteReq.Types.Options.ExpectedStreamRevisionOneofCase.StreamExists => AnyStreamRevision.StreamExists.ToInt64(), _ => throw new InvalidOperationException() }; var user = context.GetHttpContext().User; var op = DeleteOperation.WithParameter(Plugins.Authorization.Operations.Streams.Parameters.StreamId(streamName)); if (!await _provider.CheckAccessAsync(user, op, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } var requiresLeader = GetRequiresLeader(context.RequestHeaders); var position = await DeleteInternal(streamName, expectedVersion, user, false, requiresLeader, context.CancellationToken).ConfigureAwait(false); return(position.HasValue ? new DeleteResp { Position = new DeleteResp.Types.Position { CommitPosition = position.Value.CommitPosition, PreparePosition = position.Value.PreparePosition } } : new DeleteResp { NoPosition = new Empty() }); }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var deletedSource = new TaskCompletionSource <bool>(); var options = request.Options; var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, DeleteOperation, context.CancellationToken) .ConfigureAwait(false)) { throw AccessDenied(); } var name = options.Name; var deleteCheckpointStream = options.DeleteCheckpointStream; var deleteStateStream = options.DeleteStateStream; var deleteEmittedStreams = options.DeleteEmittedStreams; var runAs = new ProjectionManagementMessage.RunAs(user); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish(new ProjectionManagementMessage.Command.Delete(envelope, name, runAs, deleteCheckpointStream, deleteStateStream, deleteEmittedStreams)); await deletedSource.Task.ConfigureAwait(false); return(new DeleteResp()); void OnMessage(Message message) { if (!(message is ProjectionManagementMessage.Updated)) { deletedSource.TrySetException(UnknownMessage <ProjectionManagementMessage.Updated>(message)); return; } deletedSource.TrySetResult(true); } }
public IActionResult DeleteAlbum(DeleteReq req) { var res = _svc.DeleteAlbum(req.MaAB); return(Ok(res)); }
public IActionResult DeleteProduct(DeleteReq req) { var res = _svc.DeleteProduct(req.id); return(Ok(res)); }
public IActionResult DeleteDemId(DeleteReq req) { var res = _svc.DeleteDemId(req.id); return(Ok(res)); }
public override async Task <DeleteResp> Delete(DeleteReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <DeleteResp>(); var correlationId = Guid.NewGuid(); var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, DeleteOperation, context.CancellationToken).ConfigureAwait(false)) { throw RpcExceptions.AccessDenied(); } string streamId = null; switch (request.Options.StreamOptionCase) { case StreamOptionOneofCase.StreamIdentifier: { streamId = request.Options.StreamIdentifier; _publisher.Publish(new ClientMessage.DeletePersistentSubscriptionToStream( correlationId, correlationId, new CallbackEnvelope(HandleDeletePersistentSubscriptionCompleted), streamId, request.Options.GroupName, user)); break; } case StreamOptionOneofCase.All: streamId = SystemStreams.AllStream; _publisher.Publish(new ClientMessage.DeletePersistentSubscriptionToAll( correlationId, correlationId, new CallbackEnvelope(HandleDeletePersistentSubscriptionCompleted), request.Options.GroupName, user)); break; default: throw new InvalidOperationException(); } return(await createPersistentSubscriptionSource.Task.ConfigureAwait(false)); void HandleDeletePersistentSubscriptionCompleted(Message message) { if (message is ClientMessage.NotHandled notHandled && RpcExceptions.TryHandleNotHandled(notHandled, out var ex)) { createPersistentSubscriptionSource.TrySetException(ex); return; } if (streamId != SystemStreams.AllStream) { if (message is ClientMessage.DeletePersistentSubscriptionToStreamCompleted completed) { switch (completed.Result) { case DeletePersistentSubscriptionToStreamResult.Success: createPersistentSubscriptionSource.TrySetResult(new DeleteResp()); return; case DeletePersistentSubscriptionToStreamResult.Fail: createPersistentSubscriptionSource.TrySetException( RpcExceptions.PersistentSubscriptionFailed(streamId, request.Options.GroupName, completed.Reason)); return; case DeletePersistentSubscriptionToStreamResult.DoesNotExist: createPersistentSubscriptionSource.TrySetException( RpcExceptions.PersistentSubscriptionDoesNotExist(streamId, request.Options.GroupName)); return; case DeletePersistentSubscriptionToStreamResult.AccessDenied: createPersistentSubscriptionSource.TrySetException(RpcExceptions.AccessDenied()); return; default: createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownError(completed.Result)); return; } } createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownMessage <ClientMessage.DeletePersistentSubscriptionToStreamCompleted>(message)); } else { if (message is ClientMessage.DeletePersistentSubscriptionToAllCompleted completedAll) { switch (completedAll.Result) { case DeletePersistentSubscriptionToAllResult.Success: createPersistentSubscriptionSource.TrySetResult(new DeleteResp()); return; case DeletePersistentSubscriptionToAllResult.Fail: createPersistentSubscriptionSource.TrySetException( RpcExceptions.PersistentSubscriptionFailed(streamId, request.Options.GroupName, completedAll.Reason)); return; case DeletePersistentSubscriptionToAllResult.DoesNotExist: createPersistentSubscriptionSource.TrySetException( RpcExceptions.PersistentSubscriptionDoesNotExist(streamId, request.Options.GroupName)); return; case DeletePersistentSubscriptionToAllResult.AccessDenied: createPersistentSubscriptionSource.TrySetException(RpcExceptions.AccessDenied()); return; default: createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownError(completedAll.Result)); return; } } createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownMessage <ClientMessage.DeletePersistentSubscriptionToAllCompleted>(message)); } } }
public IActionResult DeleteNguoiDung(DeleteReq req) { var res = _svc.DeleteNguoiDung(req.MaUser); return(Ok(res)); }
public IActionResult DeleteCategory(DeleteReq req) { var res = _svc.DeleteCategory(req.id); return(Ok(res)); }
public IActionResult DeleteQuanTriVien(DeleteReq req) { var res = _svc.DeleteQuanTriVien(req.MaQuanTri); return(Ok(res)); }
public IActionResult DeleteCasi(DeleteReq req) { var res = _svc.DeleteCasi(req.MaCaSi); return(Ok(res)); }
public IActionResult DeleteTheLoai(DeleteReq req) { var res = _svc.DeleteTheLoai(req.MaTheLoai); return(Ok(res)); }
public IActionResult DeleteBaiHat(DeleteReq req) { var res = _svc.DeleteBaiHat(req.MaBaiHat); return(Ok(res)); }
public IActionResult DeleteManufacturer(DeleteReq req) { var res = _svc.DeleteManufacturer(req.id); return(Ok(res)); }
public IActionResult DeleteOrderdetail(DeleteReq req) { var res = _svc.DeleteOrderdetail(req.id); return(Ok(res)); }
public IActionResult DeletePlayList(DeleteReq req) { var res = _svc.DeletePlayList(req.MaPlayList); return(Ok(res)); }
public IActionResult DeleteTinTuc(DeleteReq req) { var res = _svc.DeleteTinTuc(req.id); return(Ok(res)); }
public IActionResult DeleteCustomer(DeleteReq req) { var res = _svc.DeleteCustomer(req.id); return(Ok(res)); }