示例#1
0
        /// <summary>
        /// Gets the by entity.
        /// </summary>
        /// <param name="entityTypeid">The entity typeid.</param>
        /// <param name="entityTypeQualifierColumn">The entity type qualifier column.</param>
        /// <param name="entityTypeQualifierValue">The entity type qualifier value.</param>
        /// <param name="includeNonSelectable">if set to <c>true</c> [include non selectable].</param>
        /// <returns></returns>
        public static List <NoteTypeCache> GetByEntity(int?entityTypeid, string entityTypeQualifierColumn, string entityTypeQualifierValue, bool includeNonSelectable = false)
        {
            LoadEntityNoteTypes();

            var matchingNoteTypeIds = AllEntityNoteTypes
                                      .Where(a => a.EntityTypeId.Equals(entityTypeid))
                                      .ToList()
                                      .Where(a =>
                                             (a.EntityTypeQualifierColumn ?? string.Empty) == (entityTypeQualifierColumn ?? string.Empty) &&
                                             (a.EntityTypeQualifierValue ?? string.Empty) == (entityTypeQualifierValue ?? string.Empty))
                                      .SelectMany(a => a.NoteTypeIds)
                                      .ToList();

            var noteTypes = new List <NoteTypeCache>();

            foreach (int noteTypeId in matchingNoteTypeIds)
            {
                var noteType = NoteTypeCache.Read(noteTypeId);
                if (noteType != null && (includeNonSelectable || noteType.UserSelectable))
                {
                    noteTypes.Add(noteType);
                }
            }

            return(noteTypes);
        }
示例#2
0
 /// <summary>
 /// Adds NoteType model to cache, and returns cached object
 /// </summary>
 /// <param name="NoteTypeModel">The NoteTypeModel to cache</param>
 /// <returns></returns>
 public static NoteTypeCache Read(Rock.Model.NoteType NoteTypeModel)
 {
     return(GetOrAddExisting(NoteTypeCache.CacheKey(NoteTypeModel.Id),
                             () => LoadByModel(NoteTypeModel)));
 }
示例#3
0
 /// <summary>
 /// Removes NoteType from cache
 /// </summary>
 /// <param name="id">The id of the NoteType to remove from cache</param>
 public static void Flush(int id)
 {
     FlushCache(NoteTypeCache.CacheKey(id));
 }
示例#4
0
 /// <summary>
 /// Returns NoteType object from cache.  If NoteType does not already exist in cache, it
 /// will be read and added to cache
 /// </summary>
 /// <param name="id">The id of the NoteType to read</param>
 /// <param name="rockContext">The rock context.</param>
 /// <returns></returns>
 public static NoteTypeCache Read(int id, RockContext rockContext = null)
 {
     return(GetOrAddExisting(NoteTypeCache.CacheKey(id),
                             () => LoadById(id, rockContext)));
 }