Beispiel #1
0
        public async Task <IActionResult> DeleteSomeData(Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var deleteSomeDataCommand = new DeleteSomeDataCommand(id);

            await _commandBus.Send(deleteSomeDataCommand);

            return(Ok());
        }
Beispiel #2
0
        public Task <Unit> Handle(DeleteSomeDataCommand request, CancellationToken cancellationToken)
        {
            try
            {
                using (var context = _dbContext)
                {
                    var aggregate = _someDataWriteRepository.Get(request.Id, context);
                    _someDataWriteRepository.Delete(aggregate, context);

                    context.SaveChanges();
                }

                _eventBus.Publish(new SomeDataDeletedEvent(request.Id));

                return(Unit.Task);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }