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); }
public async Task <IEnumerable <IWelcomeRegulationRule> > GetByRegulationIdAsync(string regulationId) { IRegulation result = await _regulationRepository.GetAsync(regulationId); if (result == null) { throw new ServiceException("Regulation not found."); } return(await _welcomeRegulationRuleRepository.GetByRegulationIdAsync(regulationId)); }