Exemplo n.º 1
0
        public async Task DeleteAsync(int id)
        {
            try
            {
                var offer = await _offerDataProvider.GetByRequestIdAsync(id);

                var message = $"Request {id} cannot be deleted because offer {offer.Id} is attached to it.";
                _logger.LogError(message);
                throw new InvalidOperationException(message);
            }
            catch (EntityNotFoundException)
            {
                await _documentGenerationManager.DeleteVisitReportAsync(id);

                await _requestDataProvider.DeleteByIdAsync(id);
            }
        }