Пример #1
0
        private void ValidateFromToValue(List <CreateClashException> command)
        {
            var clashFromCode = command?.Where(_ => _.FromType == ClashExceptionType.Clash)
                                .Select(_ => _.FromValue).Distinct(StringComparer.OrdinalIgnoreCase);
            var clashToCode = command?.Where(_ => _.ToType == ClashExceptionType.Clash)
                              .Select(_ => _.ToValue).Distinct(StringComparer.OrdinalIgnoreCase);
            var clashCode = (clashFromCode ?? Enumerable.Empty <string>())
                            .Union(clashToCode ?? Enumerable.Empty <string>()).ToList();

            if (clashCode.Any())
            {
                _clashRepository.ValidateClashCodes(clashCode);
            }

            var productFromCode = command?.Where(_ => _.FromType == ClashExceptionType.Product)
                                  .Select(_ => _.FromValue).Distinct(StringComparer.OrdinalIgnoreCase);
            var productToCode = command?.Where(_ => _.ToType == ClashExceptionType.Product)
                                .Select(_ => _.ToValue).Distinct(StringComparer.OrdinalIgnoreCase);
            var productCode = (productFromCode ?? Enumerable.Empty <string>())
                              .Union(productToCode ?? Enumerable.Empty <string>()).ToList();

            if (productCode.Any())
            {
                _productRepository.ValidateProductExternalIds(productCode);
            }

            var advertiserPeriodInfos = command.SelectMany(c => c.GetAdvertiserPeriodInfo()).ToArray();

            _productAdvertiserValidator.Validate(advertiserPeriodInfos);
        }