コード例 #1
0
        public async Task <Unit> Handle(DeleteAllergenCommand request, CancellationToken cancellationToken)
        {
            try
            {
                await _repository.Delete(request.Id, cancellationToken);

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

                return(Unit.Value);
            }
            catch (Exception e)
            {
                throw new DeleteException(request.Id, e);
            }
        }
コード例 #2
0
        public async Task <Unit> Handle(DeleteItemCommand request, CancellationToken cancellationToken)
        {
            try
            {
                await _repository.Delete(request.Id, cancellationToken);

                _logger.LogInformation("Sending deleted item event...");
                _eventBus.Publish(new ItemDeletedEvent(request.Id));

                return(Unit.Value);
            }
            catch (Exception e)
            {
                throw new DeleteException(request.Id, e);
            }
        }
コード例 #3
0
        public async Task <bool?> DeleteTransactions()
        {
            try
            {
                var transactions = await _rep.Get();

                foreach (var transaction in transactions)
                {
                    _rep.Delete(transaction);
                }
                if (!_rep.Save())
                {
                    return(null);
                }
                return(true);
            }
            catch (Exception e)
            {
                _logger.LogInformation(e.Message);
                throw;
            }
        }
コード例 #4
0
        public async Task <bool?> DeleteProperty(int id)
        {
            try
            {
                if (!_rep.Exists(id))
                {
                    return(false);
                }
                var entityToDelete = await _rep.Get(id);

                _rep.Delete(entityToDelete);
                if (!_rep.Save())
                {
                    return(null);
                }
                return(true);
            }
            catch (Exception e)
            {
                //Logger.ErrorException(e.Message, e);
                throw;
            }
        }