Beispiel #1
0
        private static FieldSetInfo BuildFieldSetInfo(fieldsets fieldset, IDatabaseEntity entity, bool announce = false)
        {
            if (fieldset == null)
                return null;

            var result = new FieldSetInfo
            {
                Id = fieldset.id,
                Title = fieldset.title,
                Url = fieldset.url,
                ShowGallery = fieldset.show_gallery,
                ShowMap = fieldset.show_map
            };

            var fields = new List<entity_fields>();
            if (announce)
            {
                fields = Meridian.Default.entity_fieldsStore.All()
                    .Where(item => item.fieldsets_items.Any(f => f.id == fieldset.id))
                    .OrderBy(item => item.announce_order).ToList();
            }
            else
            {
                var fieldsOrders = Meridian.Default.fieldset_fields_orderStore.All()
                    .Where(item => item.fieldset_id == fieldset.id)
                    .OrderBy(item => item.order_number).ToList();
                foreach (var fieldOrder in fieldsOrders)
                {
                    var item = fieldset.fieldsets_items.Find(f => f.id == fieldOrder.field_id);
                    if (item != null)
                    {
                        fields.Add(item);
                    }
                }
            }

            foreach (var field in fields)
            {
                var fieldValue = Meridian.Default.field_valuesStore.All()
                        .FirstOrDefault(item =>
                            item.proto_name == entity.ProtoName && item.field_id == field.id && item.entity_id == entity.id);

                if (fieldValue != null || (!string.IsNullOrEmpty(field.controller) && !string.IsNullOrEmpty(field.action)))
                {
                    result.Fields.Add(new FieldInfo
                    {
                        Title = field.title,
                        Value = fieldValue != null ? fieldValue.field_value : string.Empty,
                        Controller = field.controller,
                        Action = field.action
                    });
                }
            }

            return result;
        }
Beispiel #2
0
 public FieldsetMediator(IDatabaseEntity parent, fieldsets fieldSet)
 {
     m_Parent = parent;
     m_Fieldsets = fieldSet;
 }