public CultureViewModel Build(Culture culture)
 {
     return new CultureViewModel()
       {
     Code = culture.Code,
     Name = culture.Name
       };
 }
        private CachedFieldOption CacheFieldOption(Culture culture, FieldOption fieldOption)
        {
            CachedFieldOption cachedFieldOption = new CachedFieldOption();

              cachedFieldOption.FieldOptionId = fieldOption.Id;
              cachedFieldOption.Value = this.GetLocalizationValue(culture.Id, fieldOption.ValueId);
              cachedFieldOption.Position = fieldOption.Position;
              return cachedFieldOption;
        }
        private CachedDataSource CacheDataSource(Culture culture, DataSource dataSource)
        {
            CachedDataSource cachedDataSource = new CachedDataSource();

              cachedDataSource.DataSourceId = dataSource.Id;
              cachedDataSource.CSharpClassName = dataSource.CSharpClassName;
              cachedDataSource.Parameters = dataSource.Parameters;
              cachedDataSource.Code = dataSource.Code;
              return cachedDataSource;
        }
        public Culture Map(CreateOrEditViewModel createOrEdit)
        {
            Culture culture = new Culture();

              if (createOrEdit.Id != null)
            culture = this.handler.Storage.GetRepository<ICultureRepository>().WithKey((int)createOrEdit.Id);

              culture.Code = createOrEdit.Code;
              culture.Name = createOrEdit.Name;
              return culture;
        }
        private CachedMenu CacheMenu(Culture culture, Menu menu)
        {
            List<CachedMenuItem> cachedMenuItems = new List<CachedMenuItem>();

              foreach (MenuItem menuItem in this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuId(menu.Id))
            cachedMenuItems.Add(this.CacheMenuItem(culture, menuItem));

              CachedMenu cachedForm = new CachedMenu();

              cachedForm.MenuId = menu.Id;
              cachedForm.CultureId = culture.Id;
              cachedForm.Code = menu.Code;

              if (cachedMenuItems.Count != 0)
            cachedForm.CachedMenuItems = this.SerializeObject(cachedMenuItems);

              return cachedForm;
        }
        private CachedMenuItem CacheMenuItem(Culture culture, MenuItem menuItem)
        {
            List<CachedMenuItem> cachedChildMenuItems = new List<CachedMenuItem>();

              foreach (MenuItem childMenuItem in this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id))
            cachedChildMenuItems.Add(this.CacheMenuItem(culture, childMenuItem));

              CachedMenuItem cachedMenuItem = new CachedMenuItem();

              cachedMenuItem.MenuItemId = menuItem.Id;
              cachedMenuItem.Name = this.GetLocalizationValue(culture.Id, menuItem.NameId);
              cachedMenuItem.Url = menuItem.Url;
              cachedMenuItem.Position = menuItem.Position;

              if (cachedChildMenuItems.Count != 0)
            cachedMenuItem.CachedMenuItems = this.SerializeObject(cachedChildMenuItems);

              return cachedMenuItem;
        }
        private CachedField CacheField(Culture culture, Field field)
        {
            List<CachedFieldOption> cachedFieldOptions = new List<CachedFieldOption>();

              foreach (FieldOption fieldOption in this.handler.Storage.GetRepository<IFieldOptionRepository>().FilteredByFieldId(field.Id))
            cachedFieldOptions.Add(this.CacheFieldOption(culture, fieldOption));

              CachedField cachedField = new CachedField();

              cachedField.FieldId = field.Id;
              cachedField.FieldTypeCode = this.handler.Storage.GetRepository<IFieldTypeRepository>().WithKey(field.FieldTypeId).Code;
              cachedField.Name = this.GetLocalizationValue(culture.Id, field.NameId);
              cachedField.Position = field.Position;

              if (cachedFieldOptions.Count != 0)
            cachedField.CachedFieldOptions = this.SerializeObject(cachedFieldOptions);

              return cachedField;
        }
        private CachedObject CacheObject(Culture culture, Object @object)
        {
            Class @class = this.handler.Storage.GetRepository<IClassRepository>().WithKey(@object.ClassId);
              List<CachedProperty> cachedProperties = new List<CachedProperty>();

              foreach (Member member in this.handler.Storage.GetRepository<IMemberRepository>().FilteredByClassId(@class.Id))
              {
            if (member.PropertyDataTypeId != null)
            {
              Property property = this.handler.Storage.GetRepository<IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id);

              cachedProperties.Add(this.CacheProperty(culture, property));
            }
              }

              List<CachedDataSource> cachedDataSources = new List<CachedDataSource>();

              foreach (DataSource dataSource in this.handler.Storage.GetRepository<IDataSourceRepository>().FilteredByClassId(@class.Id))
            cachedDataSources.Add(this.CacheDataSource(culture, dataSource));

              CachedObject cachedObject = new CachedObject();

              cachedObject.ObjectId = @object.Id;
              cachedObject.ClassId = @class.Id;
              cachedObject.ClassViewName = @class.ViewName;
              cachedObject.Url = @object.Url;
              cachedObject.CultureId = culture.Id;

              if (cachedProperties.Count != 0)
            cachedObject.CachedProperties = this.SerializeObject(cachedProperties);

              if (cachedDataSources.Count != 0)
            cachedObject.CachedDataSources = this.SerializeObject(cachedDataSources);

              return cachedObject;
        }
        private CachedProperty CacheProperty(Culture culture, Property property)
        {
            CachedProperty cachedProperty = new CachedProperty();

              cachedProperty.PropertyId = property.Id;
              cachedProperty.MemberCode = this.handler.Storage.GetRepository<IMemberRepository>().WithKey(property.MemberId).Code;
              cachedProperty.Html = this.GetLocalizationValue(culture.Id, property.HtmlId);
              return cachedProperty;
        }
Beispiel #10
0
        private CachedForm CacheForm(Culture culture, Form form)
        {
            List<CachedField> cachedFields = new List<CachedField>();

              foreach (Field field in this.handler.Storage.GetRepository<IFieldRepository>().FilteredByFormId(form.Id))
            cachedFields.Add(this.CacheField(culture, field));

              CachedForm cachedForm = new CachedForm();

              cachedForm.FormId = form.Id;
              cachedForm.CultureId = culture.Id;
              cachedForm.Code = form.Code;
              cachedForm.Name = this.GetLocalizationValue(culture.Id, form.NameId);

              if (cachedFields.Count != 0)
            cachedForm.CachedFields = this.SerializeObject(cachedFields);

              return cachedForm;
        }