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);
            }
        }
        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);
            }
        }
Example #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;
            }
        }
        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;
            }
        }