Esempio n. 1
0
        private async Task ValidateConfigurationSettingAsync(ConfigurationSettingDto configuration)
        {
            if (string.IsNullOrEmpty(configuration.Section))
            {
                throw new YawnMassageException("ERR_SECTION_CANNOT_BE_NULL");
            }

            if (string.IsNullOrEmpty(configuration.Culture))
            {
                throw new YawnMassageException("ERR_CULTURE_CANNOT_BE_NULL");
            }

            if (string.IsNullOrEmpty(configuration.Value))
            {
                throw new YawnMassageException("ERR_VALUE_CANNOT_BE_NULL");
            }

            if (string.IsNullOrEmpty(configuration.Key))
            {
                throw new YawnMassageException("ERR_KEY_CANNOT_BE_NULL");
            }

            var exists = await _dataContext.AnyAsync <ConfigurationSetting>(q => q.Where(d =>
                                                                                         d.Key == configuration.Key &&
                                                                                         d.GroupId == configuration.GroupId &&
                                                                                         d.Culture == configuration.Culture &&
                                                                                         d.Section == configuration.Section &&
                                                                                         (configuration.Id == null || d.Id != configuration.Id)));

            if (exists)
            {
                throw new DocumentDuplicateException();
            }
        }
Esempio n. 2
0
        private async Task CheckForDuplicates(string role, string selfId = null)
        {
            var exists = await _dataContext.AnyAsync <PermissionConfig>(q => q.Where(p =>
                                                                                     p.Role == role &&
                                                                                     (selfId == null || p.Id != selfId)));

            if (exists)
            {
                throw new DocumentDuplicateException();
            }
        }
        private async Task CheckForDuplicates(LocalisationTextDto localisationTextDto)
        {
            var exists = await _dataContext.AnyAsync <LocalisationText>(q => q.Where(d =>
                                                                                     d.Key == localisationTextDto.Key &&
                                                                                     d.GroupId == localisationTextDto.GroupId &&
                                                                                     d.Culture == localisationTextDto.Culture &&
                                                                                     d.Section == localisationTextDto.Section &&
                                                                                     (localisationTextDto.Id == null || d.Id != localisationTextDto.Id)));

            if (exists)
            {
                throw new DocumentDuplicateException();
            }
        }
Esempio n. 4
0
        private async Task CheckForDuplicates(string group, string culture, string section, string key, string selfId = null)
        {
            var exists = await _dataContext.AnyAsync <Lookup>(q => q.Where(l => l.Key == key &&
                                                                           !l.IsDeleted &&
                                                                           l.GroupId == group &&
                                                                           l.Culture == culture &&
                                                                           l.Section == section &&
                                                                           (selfId == null || l.Id != selfId)));

            if (exists)
            {
                throw new DocumentDuplicateException();
            }
        }
        private async Task CheckForDuplicatesAsync(AlertTemplateDto dto)
        {
            var exists = await _dataContext.AnyAsync <AlertTemplate>(q => q.Where(d =>
                                                                                  d.Key == dto.Key &&
                                                                                  d.GroupId == dto.GroupId &&
                                                                                  d.Culture == dto.Culture &&
                                                                                  d.Section == dto.Section &&
                                                                                  d.Channel == dto.Channel &&
                                                                                  (dto.Id == null || d.Id != dto.Id)));

            if (exists)
            {
                throw new DocumentDuplicateException();
            }
        }