Exemplo n.º 1
0
        // -------------------------------------------------------------------- widget areas

        /// <summary>
        /// Registers a widget area by its id and type.
        /// </summary>
        /// <param name="areaId">The id of the widget area.</param>
        /// <param name="type">The <see cref="EMetaType"/> of the area.</param>
        /// <returns></returns>
        public async Task <Meta> RegisterAreaAsync(string areaId, EMetaType type = EMetaType.WidgetAreaBySystem)
        {
            var key = areaId;

            if (IsThemeDefinedArea(areaId))
            {
                key = await GetThemeAreaMetaKeyAsync(areaId);

                type = EMetaType.WidgetAreaByTheme;
            }

            return(await metaRepository.CreateAsync(new Meta
            {
                Key = key,
                Value = JsonConvert.SerializeObject(new WidgetArea {
                    Id = areaId
                }),
                Type = type,
            }));
        }
Exemplo n.º 2
0
 public async Task <List <Meta> > GetListAsync(EMetaType type) =>
 await _entities.Where(m => m.Type == type).ToListAsync();
Exemplo n.º 3
0
 /// <summary>
 /// Returns a <see cref="Meta"/> by its key (case-insensitive) and <see cref="EMetaType"/>, returns null if it's not found.
 /// </summary>
 /// <param name="key">The key's casing is ignored.</param>
 /// <param name="type">The <see cref="EMetaType"/> of the meta.</param>
 /// <returns></returns>
 /// <remarks>
 /// A meta record is unique by combination of key and type.
 /// </remarks>
 public async Task <Meta> GetAsync(string key, EMetaType type) =>
 await _entities.SingleOrDefaultAsync(m => m.Key.Equals(key, StringComparison.OrdinalIgnoreCase) &&
                                      m.Type == type);
Exemplo n.º 4
0
 /// <summary>
 /// Returns a <see cref="Meta"/> by its key (case-sensitive) and type, returns null if it's not found.
 /// </summary>
 /// <param name="key">The caller should pass this key in proper casing.</param>
 /// <param name="type">The <see cref="EMetaType"/> of the meta.</param>
 /// <returns></returns>
 /// <remarks>
 /// A meta record is unique by combination of key and type.
 /// </remarks>
 public async Task <Meta> GetAsync(string key, EMetaType type) =>
 await _entities.SingleOrDefaultAsync(m => m.Key == key && m.Type == type);