コード例 #1
0
        public async Task DeleteAsync(string regulationId)
        {
            IRegulation regulation = await _regulationRepository.GetAsync(regulationId);

            if (regulation == null)
            {
                throw new ServiceException("Regulation not found.");
            }

            IEnumerable <IClientRegulation> clientAvailableRegulations =
                await _clientRegulationRepository.GetByRegulationIdAsync(regulationId);

            if (clientAvailableRegulations.Any())
            {
                throw new ServiceException("Can not delete regulation associated with one or more clients.");
            }

            IEnumerable <IWelcomeRegulationRule> welcomeRegulationRules =
                await _welcomeRegulationRuleRepository.GetByRegulationIdAsync(regulationId);

            if (welcomeRegulationRules.Any())
            {
                throw new ServiceException("Can not delete regulation associated with one or more welcome rules.");
            }

            await _regulationRepository.DeleteAsync(regulationId);
        }