Example #1
0
        public async Task <bool> Handle(DeleteApiCommand message, CancellationToken cancellationToken)
        {
            var client = await _repository.GetById(message.Id) ?? throw new KeyNotFoundException();

            await _repository.Delete(message.Id);

            return(true);
        }
Example #2
0
        public async Task <IActionResult> Delete([FromRoute] Guid id)
        {
            var command = new DeleteApiCommand {
                Id = id
            };
            await _mediator.Send(command);

            return(Ok());
        }
Example #3
0
        public async Task <IActionResult> Delete(DeleteApiCommand command)
        {
            try
            {
                await _mediator.Send(command);

                return(Ok());
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound());
            }
            catch (ArgumentException argumentException)
            {
                return(BadRequest(argumentException.Message));
            }
        }