Esempio n. 1
0
        private void RaiseItemEditInteractionRequest(MappingItem originalItem)
        {
            var item             = originalItem.DeepClone(EntityFactory as ImportJobEntityFactory);
            var selectedProperty = AvailableImporters.First(importer => importer.Name == InnerItem.EntityImporter).SystemProperties.FirstOrDefault(prop => prop.Name == item.EntityColumnName);
            var param            = new ColumnMappingEntity
            {
                MappingItem    = item,
                CsvColumnsList = CsvFileColumns,
                ImportProperty = selectedProperty
            };

            var itemVM = _mappingVmFactory.GetViewModelInstance(
                new KeyValuePair <string, object>("item", param)
                );

            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Title = "Edit column mapping".Localize(), Content = itemVM
            };

            CommonConfirmRequest2.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    var innerItemProp = InnerItem.PropertiesMap.FirstOrDefault(prop => prop.EntityColumnName == item.EntityColumnName && prop.Locale == item.Locale);

                    if (innerItemProp != null)
                    {
                        // copy all values to original:
                        if (!string.IsNullOrEmpty(item.CustomValue) && (item.CsvColumnName == CustomString || string.IsNullOrEmpty(item.CsvColumnName)))
                        {
                            innerItemProp.Locale       = item.Locale;
                            originalItem.CustomValue   = innerItemProp.CustomValue = item.CustomValue;
                            originalItem.CsvColumnName = innerItemProp.CsvColumnName = null;
                            originalItem.StringFormat  = innerItemProp.StringFormat = item.StringFormat;
                        }
                        else
                        {
                            innerItemProp.Locale       = item.Locale;
                            originalItem.CsvColumnName = innerItemProp.CsvColumnName = item.CsvColumnName;
                            originalItem.CustomValue   = innerItemProp.CustomValue = null;
                            originalItem.StringFormat  = innerItemProp.StringFormat = item.StringFormat;
                        }
                    }

                    OnIsValidChanged();
                }
            });
        }
        private void RaiseItemEditInteractionRequest(MappingItem originalItem)
        {
            var item = originalItem.DeepClone <MappingItem>(_entityFactory as CatalogEntityFactory);

            var param = new ColumnMappingEntity {
                MappingItem = item, CsvColumnsList = CsvFileColumns
            };

            //var csvNames = new List<string>();
            //SelectedMappingItems.Where(y => !String.IsNullOrEmpty(y.CsvColumnName)).ToList().ForEach(x => csvNames.Add(x.CsvColumnName));
            //param.CsvColumnsList = csvNames.ToArray();
            _columnMappingVM.InnerItem = param;

            var confirmation = new ConditionalConfirmation();

            confirmation.Title   = "Edit column mapping";
            confirmation.Content = _columnMappingVM;

            CommonConfirmRequest2.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    // copy all values to original:
                    if (!String.IsNullOrEmpty(item.CustomValue) && (item.CsvColumnName == "Custom" || String.IsNullOrEmpty(item.CsvColumnName)))
                    {
                        originalItem.CustomValue   = item.CustomValue;
                        originalItem.CsvColumnName = null;                         // String.Empty;
                    }
                    else
                    {
                        originalItem.CsvColumnName = item.CsvColumnName;
                        originalItem.CustomValue   = null;                       // String.Empty;
                    }
                    // fake assign for UI triggers to display updated values.
                    //originalItem.MappingItemId = item.MappingItemId;
                    //SelectedColumnMapping = InnerItem.ColumnMapping;

                    if (IsSingleDialogEditing)
                    {
                        IsModified = true;
                    }
                }
            });
        }
        private void RaiseItemEditInteractionRequest(MappingItem originalItem)
        {
            var item             = originalItem.DeepClone <MappingItem>(_entityFactory as CatalogEntityFactory);
            var selectedProperty = SelectedEntityImporter.SystemProperties.First(prop => prop.Name == item.EntityColumnName);
            var param            = new ColumnMappingEntity {
                MappingItem = item, CsvColumnsList = CsvFileColumns, ImportProperty = selectedProperty
            };

            var itemVM = Container.Resolve <IColumnMappingViewModel>(
                new ParameterOverride("item", param)
                );

            var confirmation = new ConditionalConfirmation(itemVM.Validate);

            confirmation.Title   = "Edit column mapping";
            confirmation.Content = itemVM;

            CommonConfirmRequest2.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    // copy all values to original:
                    if (!String.IsNullOrEmpty(item.CustomValue) && (item.CsvColumnName == "Custom" || String.IsNullOrEmpty(item.CsvColumnName)))
                    {
                        originalItem.CustomValue   = item.CustomValue;
                        originalItem.CsvColumnName = null;                         // String.Empty;
                    }
                    else
                    {
                        originalItem.CsvColumnName = item.CsvColumnName;
                        originalItem.CustomValue   = null;                       // String.Empty;
                    }
                    // fake assign for UI triggers to display updated values.
                    //originalItem.MappingItemId = item.MappingItemId;
                    //SelectedColumnMapping = InnerItem.ColumnMapping;

                    if (IsSingleDialogEditing)
                    {
                        IsModified = true;
                    }
                }
            });
        }