Esempio n. 1
0
        private bool ValidateKeywords()
        {
            var retVal   = true;
            var keywords = SeoKeywords.Where(key => !string.IsNullOrEmpty(key.Keyword)).ToList();

            if (keywords.Any())
            {
                using (var appConfigRepository = _appConfigRepositoryFactory.GetRepositoryInstance())
                {
                    keywords.ForEach(keyword =>
                    {
                        if (retVal)
                        {
                            var count = appConfigRepository.SeoUrlKeywords
                                        .Where(x =>
                                               x.SeoUrlKeywordId != keyword.SeoUrlKeywordId &&
                                               x.Keyword == keyword.Keyword && x.KeywordType == keyword.KeywordType && x.Language == keyword.Language && x.IsActive == keyword.IsActive)
                                        .Count();

                            if (count > 0)
                            {
                                keyword.SetError("Keyword", "Item with the same Keyword and Language already exists", true);
                                CurrentSeoKeyword = keyword;
                                RaiseSeoLocalesFilter(keyword.Language);
                                retVal = false;
                            }
                        }
                    });
                }
            }

            return(retVal);
        }
        private bool ValidateKeywords()
        {
            var retVal   = true;
            var keywords = SeoKeywords.Where(key => !string.IsNullOrEmpty(key.Keyword)).ToList();

            if (keywords.Any())
            {
                using (var appConfigRepository = _appConfigRepositoryFactory.GetRepositoryInstance())
                {
                    keywords.ForEach(keyword =>
                    {
                        if (retVal)
                        {
                            var count = appConfigRepository.SeoUrlKeywords
                                        .Where(x =>
                                               !x.SeoUrlKeywordId.Equals(keyword.SeoUrlKeywordId, StringComparison.InvariantCultureIgnoreCase) &&
                                               x.Keyword.Equals(keyword.Keyword, StringComparison.InvariantCultureIgnoreCase) && x.KeywordType == keyword.KeywordType && x.Language.Equals(keyword.Language, StringComparison.InvariantCultureIgnoreCase) && x.IsActive)
                                        .Count();

                            if (count > 0)
                            {
                                keyword.SetError("Keyword", string.Format("{0} with the same Keyword and Language already exists".Localize(), _keywordType.ToString()), false);
                                if (keyword.SeoUrlKeywordId.Equals(CurrentSeoKeyword.SeoUrlKeywordId, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    OnPropertyChanged("CurrentSeoKeyword");
                                }
                                retVal = false;
                            }
                        }
                    });
                }
            }

            return(retVal);
        }