Пример #1
0
        public static bool IsValid(this ClaraApplicationEntity claraApplicationEntity, IEnumerable <string> existingAeTitles, out IList <string> validationErrors)
        {
            Guard.Against.Null(claraApplicationEntity, nameof(claraApplicationEntity));
            Guard.Against.Null(existingAeTitles, nameof(existingAeTitles));

            validationErrors = new List <string>();

            var valid = true;

            valid &= IsAeTitleValid(claraApplicationEntity.GetType().Name, claraApplicationEntity.AeTitle, validationErrors);

            if (existingAeTitles.Any(p => p.Equals(claraApplicationEntity.AeTitle, StringComparison.Ordinal)))
            {
                validationErrors.Add($"Clara AE Title {claraApplicationEntity.AeTitle} already exists.");
                valid = false;
            }

            return(valid);
        }
        public bool IsClaraAeTitleValid(IList <ClaraApplicationEntity> aeTitles, string source, ClaraApplicationEntity entity, bool validateCrd = false)
        {
            Guard.Against.Null(source, nameof(source));
            Guard.Against.Null(entity, nameof(entity));

            var valid = true;

            valid &= IsAeTitleValid(source, entity.AeTitle);

            var validationCount = validateCrd ? 0 : 1;

            if (aeTitles.Count(p => p.AeTitle.Equals(entity.AeTitle, StringComparison.Ordinal)) > validationCount)
            {
                _logger.Log(LogLevel.Error, $"DicomAdapter>dicom>scp>aeTitles>{entity.AeTitle} already exists.");
                valid = false;
            }

            return(valid);
        }