/// <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); }
/// <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))); }
/// <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)); }
/// <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))); }