Esempio n. 1
0
 private void ValidatePropertySet(bool doNotifyChanges)
 {
     if (InnerItem.PropertySet == null || string.IsNullOrEmpty(InnerItem.PropertySet.PropertySetId))
     {
         InnerItem.SetError("PropertySet", "PropertySet error".Localize(), doNotifyChanges);
     }
     else
     {
         InnerItem.ClearError("PropertySet");
     }
 }
 private void ValidateDefaultCurrency(bool doNotifyChanges)
 {
     if (string.IsNullOrEmpty(InnerItem.DefaultCurrency))
     {
         InnerItem.SetError("DefaultCurrency", "Field 'Default Currency' is required.".Localize(), doNotifyChanges);
     }
     else
     {
         InnerItem.ClearError("DefaultCurrency");
     }
 }
 private void ValidateCurrencies(bool doNotifyChanges)
 {
     if (InnerItem.Currencies.Count == 0)
     {
         InnerItem.SetError("Currencies", "external validation error".Localize(), doNotifyChanges);
     }
     else
     {
         InnerItem.ClearError("Currencies");
     }
 }
 private void ValidateDefaultLanguage(bool doNotifyChanges)
 {
     if (string.IsNullOrEmpty(InnerItem.DefaultLanguage) || InnerItem.DefaultLanguage.StartsWith("Select"))
     {
         InnerItem.SetError("DefaultLanguage", "Field 'Default Language' is required.".Localize(), doNotifyChanges);
     }
     else
     {
         InnerItem.ClearError("DefaultLanguage");
     }
 }
        // function almost duplicated in ItemViewModel
        protected override bool IsValidForSave()
        {
            var result = InnerItem.Validate();

            // Code should be unique in scope of catalog
            var isCodeValid = true;

            if (InnerItem.Code != OriginalItem.Code)
            {
                var count = ItemRepository.Categories
                            .Where(x =>
                                   x.CatalogId == InnerItem.CatalogId && x.Code == InnerItem.Code && x.CategoryId != InnerItem.CategoryId)
                            .Count();

                if (count > 0)
                {
                    InnerItem.SetError("Code", "A category with this Code already exists in this catalog".Localize(), true);
                    SelectedTabIndex = TabIndexOverview;
                    isCodeValid      = false;
                }
            }

            var isPropertyValuesValid = PropertiesAndValues.All(x => x.IsValid);

            if (!isPropertyValuesValid && isCodeValid)
            {
                SelectedTabIndex = TabIndexProperties;
                var val = PropertiesAndValues.First(x => !x.IsValid);
                if (!string.IsNullOrEmpty(val.Locale) && val.Locale != FilterLanguage)
                {
                    RaisePropertiesLocalesFilter(val.Locale);
                }
            }

            var seoIsValid = true;

            if (SeoStepViewModel != null)
            {
                seoIsValid = SeoStepViewModel.IsValid;
                if (!seoIsValid)
                {
                    SelectedTabIndex = TabIndexSeo;
                }
            }

            return(result && isPropertyValuesValid && isCodeValid && seoIsValid);
        }