private App GetApp(App request) { var id = request?.Id; App ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <App>(currentUser, "App", request.Select); DocEntityApp entity = null; if (id.HasValue) { entity = DocEntityApp.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No App found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
private BackgroundTask _AssignValues(BackgroundTask request, DocConstantPermission permission, Session session) { if (permission != DocConstantPermission.ADD && (request == null || request.Id <= 0)) { throw new HttpError(HttpStatusCode.NotFound, $"No record"); } if (permission == DocConstantPermission.ADD && !DocPermissionFactory.HasPermissionTryAdd(currentUser, "BackgroundTask")) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } request.Select = request.Select ?? new List <string>(); BackgroundTask ret = null; request = _InitAssignValues <BackgroundTask>(request, permission, session); //In case init assign handles create for us, return it if (permission == DocConstantPermission.ADD && request.Id > 0) { return(request); } var cacheKey = GetApiCacheKey <BackgroundTask>(DocConstantModelName.BACKGROUNDTASK, nameof(BackgroundTask), request); //First, assign all the variables, do database lookups and conversions var pApp = DocEntityApp.Get(request.App?.Id, true, Execute) ?? DocEntityApp.Get(request.AppId, true, Execute); var pChannel = DocEntityQueueChannel.Get(request.Channel?.Id, true, Execute) ?? DocEntityQueueChannel.Get(request.ChannelId, true, Execute); var pDescription = request.Description; var pEnabled = request.Enabled; var pFrequency = request.Frequency; var pHistoryRetention = request.HistoryRetention; var pItems = GetVariable <Reference>(request, nameof(request.Items), request.Items?.ToList(), request.ItemsIds?.ToList()); var pKeepHistory = request.KeepHistory; var pLastRunVersion = request.LastRunVersion; var pLogError = request.LogError; var pLogInfo = request.LogInfo; var pName = request.Name; var pRowsToProcessPerIteration = request.RowsToProcessPerIteration; var pRunNow = request.RunNow; var pStartAt = request.StartAt; var pTaskHistory = GetVariable <Reference>(request, nameof(request.TaskHistory), request.TaskHistory?.ToList(), request.TaskHistoryIds?.ToList()); var pArchived = true == request.Archived; var pLocked = request.Locked; var entity = InitEntity <DocEntityBackgroundTask, BackgroundTask>(request, permission, session); if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pArchived, permission, nameof(request.Archived), pArchived != entity.Archived)) { entity.Archived = pArchived; } if (AllowPatchValue <BackgroundTask, DocEntityApp>(request, DocConstantModelName.BACKGROUNDTASK, pApp, permission, nameof(request.App), pApp != entity.App)) { entity.App = pApp; } if (AllowPatchValue <BackgroundTask, DocEntityQueueChannel>(request, DocConstantModelName.BACKGROUNDTASK, pChannel, permission, nameof(request.Channel), pChannel != entity.Channel)) { entity.Channel = pChannel; } if (AllowPatchValue <BackgroundTask, string>(request, DocConstantModelName.BACKGROUNDTASK, pDescription, permission, nameof(request.Description), pDescription != entity.Description)) { entity.Description = pDescription; } if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pEnabled, permission, nameof(request.Enabled), pEnabled != entity.Enabled)) { entity.Enabled = pEnabled; } if (AllowPatchValue <BackgroundTask, int?>(request, DocConstantModelName.BACKGROUNDTASK, pFrequency, permission, nameof(request.Frequency), pFrequency != entity.Frequency)) { if (null != pFrequency) { entity.Frequency = (int)pFrequency; } } if (AllowPatchValue <BackgroundTask, int?>(request, DocConstantModelName.BACKGROUNDTASK, pHistoryRetention, permission, nameof(request.HistoryRetention), pHistoryRetention != entity.HistoryRetention)) { entity.HistoryRetention = pHistoryRetention; } if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pKeepHistory, permission, nameof(request.KeepHistory), pKeepHistory != entity.KeepHistory)) { entity.KeepHistory = pKeepHistory; } if (AllowPatchValue <BackgroundTask, string>(request, DocConstantModelName.BACKGROUNDTASK, pLastRunVersion, permission, nameof(request.LastRunVersion), pLastRunVersion != entity.LastRunVersion)) { entity.LastRunVersion = pLastRunVersion; } if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pLogError, permission, nameof(request.LogError), pLogError != entity.LogError)) { entity.LogError = pLogError; } if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pLogInfo, permission, nameof(request.LogInfo), pLogInfo != entity.LogInfo)) { entity.LogInfo = pLogInfo; } if (AllowPatchValue <BackgroundTask, string>(request, DocConstantModelName.BACKGROUNDTASK, pName, permission, nameof(request.Name), pName != entity.Name)) { entity.Name = pName; } if (AllowPatchValue <BackgroundTask, int?>(request, DocConstantModelName.BACKGROUNDTASK, pRowsToProcessPerIteration, permission, nameof(request.RowsToProcessPerIteration), pRowsToProcessPerIteration != entity.RowsToProcessPerIteration)) { if (null != pRowsToProcessPerIteration) { entity.RowsToProcessPerIteration = (int)pRowsToProcessPerIteration; } } if (AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pRunNow, permission, nameof(request.RunNow), pRunNow != entity.RunNow)) { entity.RunNow = pRunNow; } if (AllowPatchValue <BackgroundTask, string>(request, DocConstantModelName.BACKGROUNDTASK, pStartAt, permission, nameof(request.StartAt), pStartAt != entity.StartAt)) { entity.StartAt = pStartAt; } if (request.Locked && AllowPatchValue <BackgroundTask, bool>(request, DocConstantModelName.BACKGROUNDTASK, pArchived, permission, nameof(request.Locked), pLocked != entity.Locked)) { entity.Archived = pArchived; } entity.SaveChanges(permission); var idsToInvalidate = new List <int>(); idsToInvalidate.AddRange(PatchCollection <BackgroundTask, DocEntityBackgroundTask, Reference, DocEntityBackgroundTaskItem>(request, entity, pItems, permission, nameof(request.Items))); idsToInvalidate.AddRange(PatchCollection <BackgroundTask, DocEntityBackgroundTask, Reference, DocEntityBackgroundTaskHistory>(request, entity, pTaskHistory, permission, nameof(request.TaskHistory))); if (idsToInvalidate.Any()) { idsToInvalidate.Add(entity.Id); DocCacheClient.RemoveByEntityIds(idsToInvalidate); DocCacheClient.RemoveSearch(DocConstantModelName.BACKGROUNDTASK); } entity.SaveChanges(permission); DocPermissionFactory.SetSelect <BackgroundTask>(currentUser, nameof(BackgroundTask), request.Select); ret = entity.ToDto(); var cacheExpires = DocResources.Metadata.GetCacheExpiration(DocConstantModelName.BACKGROUNDTASK); DocCacheClient.Set(key: cacheKey, value: ret, entityId: request.Id, entityType: DocConstantModelName.BACKGROUNDTASK, cacheExpires); return(ret); }
private History _AssignValues(History request, DocConstantPermission permission, Session session) { if (permission != DocConstantPermission.ADD && (request == null || request.Id <= 0)) { throw new HttpError(HttpStatusCode.NotFound, $"No record"); } if (permission == DocConstantPermission.ADD && !DocPermissionFactory.HasPermissionTryAdd(currentUser, "History")) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } request.Select = request.Select ?? new List <string>(); History ret = null; request = _InitAssignValues <History>(request, permission, session); //In case init assign handles create for us, return it if (permission == DocConstantPermission.ADD && request.Id > 0) { return(request); } var cacheKey = GetApiCacheKey <History>(DocConstantModelName.HISTORY, nameof(History), request); //First, assign all the variables, do database lookups and conversions var pApp = DocEntityApp.Get(request.App?.Id, true, Execute) ?? DocEntityApp.Get(request.AppId, true, Execute); var pDocumentSet = DocEntityDocumentSet.Get(request.DocumentSet?.Id, true, Execute) ?? DocEntityDocumentSet.Get(request.DocumentSetId, true, Execute); var pImpersonation = DocEntityImpersonation.Get(request.Impersonation?.Id, true, Execute) ?? DocEntityImpersonation.Get(request.ImpersonationId, true, Execute); var pPage = DocEntityPage.Get(request.Page?.Id, true, Execute) ?? DocEntityPage.Get(request.PageId, true, Execute); var pURL = request.URL; var pUser = DocEntityUser.Get(request.User?.Id, true, Execute) ?? DocEntityUser.Get(request.UserId, true, Execute); var pUserSession = DocEntityUserSession.Get(request.UserSession?.Id, true, Execute) ?? DocEntityUserSession.Get(request.UserSessionId, true, Execute); var pWorkflow = DocEntityWorkflow.Get(request.Workflow?.Id, true, Execute) ?? DocEntityWorkflow.Get(request.WorkflowId, true, Execute); var pArchived = true == request.Archived; var pLocked = request.Locked; var entity = InitEntity <DocEntityHistory, History>(request, permission, session); if (AllowPatchValue <History, bool>(request, DocConstantModelName.HISTORY, pArchived, permission, nameof(request.Archived), pArchived != entity.Archived)) { entity.Archived = pArchived; } if (AllowPatchValue <History, DocEntityApp>(request, DocConstantModelName.HISTORY, pApp, permission, nameof(request.App), pApp != entity.App)) { entity.App = pApp; } if (AllowPatchValue <History, DocEntityDocumentSet>(request, DocConstantModelName.HISTORY, pDocumentSet, permission, nameof(request.DocumentSet), pDocumentSet != entity.DocumentSet)) { entity.DocumentSet = pDocumentSet; } if (AllowPatchValue <History, DocEntityImpersonation>(request, DocConstantModelName.HISTORY, pImpersonation, permission, nameof(request.Impersonation), pImpersonation != entity.Impersonation)) { entity.Impersonation = pImpersonation; } if (AllowPatchValue <History, DocEntityPage>(request, DocConstantModelName.HISTORY, pPage, permission, nameof(request.Page), pPage != entity.Page)) { entity.Page = pPage; } if (AllowPatchValue <History, string>(request, DocConstantModelName.HISTORY, pURL, permission, nameof(request.URL), pURL != entity.URL)) { entity.URL = pURL; } if (AllowPatchValue <History, DocEntityUser>(request, DocConstantModelName.HISTORY, pUser, permission, nameof(request.User), pUser != entity.User)) { entity.User = pUser; } if (AllowPatchValue <History, DocEntityUserSession>(request, DocConstantModelName.HISTORY, pUserSession, permission, nameof(request.UserSession), pUserSession != entity.UserSession)) { entity.UserSession = pUserSession; } if (AllowPatchValue <History, DocEntityWorkflow>(request, DocConstantModelName.HISTORY, pWorkflow, permission, nameof(request.Workflow), pWorkflow != entity.Workflow)) { entity.Workflow = pWorkflow; } if (request.Locked && AllowPatchValue <History, bool>(request, DocConstantModelName.HISTORY, pArchived, permission, nameof(request.Locked), pLocked != entity.Locked)) { entity.Archived = pArchived; } entity.SaveChanges(permission); var idsToInvalidate = new List <int>(); if (idsToInvalidate.Any()) { idsToInvalidate.Add(entity.Id); DocCacheClient.RemoveByEntityIds(idsToInvalidate); DocCacheClient.RemoveSearch(DocConstantModelName.HISTORY); } entity.SaveChanges(permission); DocPermissionFactory.SetSelect <History>(currentUser, nameof(History), request.Select); ret = entity.ToDto(); var cacheExpires = DocResources.Metadata.GetCacheExpiration(DocConstantModelName.HISTORY); DocCacheClient.Set(key: cacheKey, value: ret, entityId: request.Id, entityType: DocConstantModelName.HISTORY, cacheExpires); return(ret); }
private Scope _AssignValues(Scope request, DocConstantPermission permission, Session session) { if (permission != DocConstantPermission.ADD && (request == null || request.Id <= 0)) { throw new HttpError(HttpStatusCode.NotFound, $"No record"); } if (permission == DocConstantPermission.ADD && !DocPermissionFactory.HasPermissionTryAdd(currentUser, "Scope")) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } request.Select = request.Select ?? new List <string>(); Scope ret = null; request = _InitAssignValues <Scope>(request, permission, session); //In case init assign handles create for us, return it if (permission == DocConstantPermission.ADD && request.Id > 0) { return(request); } var cacheKey = GetApiCacheKey <Scope>(DocConstantModelName.SCOPE, nameof(Scope), request); //First, assign all the variables, do database lookups and conversions var pApp = DocEntityApp.Get(request.App?.Id, true, Execute) ?? DocEntityApp.Get(request.AppId, true, Execute); var pBindings = GetVariable <Reference>(request, nameof(request.Bindings), request.Bindings?.ToList(), request.BindingsIds?.ToList()); var pBroadcasts = GetVariable <Reference>(request, nameof(request.Broadcasts), request.Broadcasts?.ToList(), request.BroadcastsIds?.ToList()); var pClient = DocEntityClient.Get(request.Client?.Id, true, Execute) ?? DocEntityClient.Get(request.ClientId, true, Execute); var pDelete = request.Delete; var pDocumentSet = DocEntityDocumentSet.Get(request.DocumentSet?.Id, true, Execute) ?? DocEntityDocumentSet.Get(request.DocumentSetId, true, Execute); var pEdit = request.Edit; var pHelp = GetVariable <Reference>(request, nameof(request.Help), request.Help?.ToList(), request.HelpIds?.ToList()); var pIsGlobal = request.IsGlobal; var pScopedComments = GetVariable <Reference>(request, nameof(request.ScopedComments), request.ScopedComments?.ToList(), request.ScopedCommentsIds?.ToList()); var pScopedFiles = GetVariable <Reference>(request, nameof(request.ScopedFiles), request.ScopedFiles?.ToList(), request.ScopedFilesIds?.ToList()); var pScopedTags = GetVariable <Reference>(request, nameof(request.ScopedTags), request.ScopedTags?.ToList(), request.ScopedTagsIds?.ToList()); var pSynonyms = GetVariable <Reference>(request, nameof(request.Synonyms), request.Synonyms?.ToList(), request.SynonymsIds?.ToList()); var pTeam = DocEntityTeam.Get(request.Team?.Id, true, Execute) ?? DocEntityTeam.Get(request.TeamId, true, Execute); var pType = request.Type; var pUser = DocEntityUser.Get(request.User?.Id, true, Execute) ?? DocEntityUser.Get(request.UserId, true, Execute); var pVariableRules = GetVariable <Reference>(request, nameof(request.VariableRules), request.VariableRules?.ToList(), request.VariableRulesIds?.ToList()); var pView = request.View; var pWorkflows = GetVariable <Reference>(request, nameof(request.Workflows), request.Workflows?.ToList(), request.WorkflowsIds?.ToList()); var pArchived = true == request.Archived; var pLocked = request.Locked; var entity = InitEntity <DocEntityScope, Scope>(request, permission, session); if (AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pArchived, permission, nameof(request.Archived), pArchived != entity.Archived)) { entity.Archived = pArchived; } if (AllowPatchValue <Scope, DocEntityApp>(request, DocConstantModelName.SCOPE, pApp, permission, nameof(request.App), pApp != entity.App)) { entity.App = pApp; } if (AllowPatchValue <Scope, DocEntityClient>(request, DocConstantModelName.SCOPE, pClient, permission, nameof(request.Client), pClient != entity.Client)) { entity.Client = pClient; } if (AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pDelete, permission, nameof(request.Delete), pDelete != entity.Delete)) { entity.Delete = pDelete; } if (AllowPatchValue <Scope, DocEntityDocumentSet>(request, DocConstantModelName.SCOPE, pDocumentSet, permission, nameof(request.DocumentSet), pDocumentSet != entity.DocumentSet)) { entity.DocumentSet = pDocumentSet; } if (AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pEdit, permission, nameof(request.Edit), pEdit != entity.Edit)) { entity.Edit = pEdit; } if (AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pIsGlobal, permission, nameof(request.IsGlobal), pIsGlobal != entity.IsGlobal)) { entity.IsGlobal = pIsGlobal; } if (AllowPatchValue <Scope, DocEntityTeam>(request, DocConstantModelName.SCOPE, pTeam, permission, nameof(request.Team), pTeam != entity.Team)) { entity.Team = pTeam; } if (AllowPatchValue <Scope, ScopeEnm?>(request, DocConstantModelName.SCOPE, pType, permission, nameof(request.Type), pType != entity.Type)) { if (null != pType) { entity.Type = pType.Value; } } if (AllowPatchValue <Scope, DocEntityUser>(request, DocConstantModelName.SCOPE, pUser, permission, nameof(request.User), pUser != entity.User)) { entity.User = pUser; } if (AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pView, permission, nameof(request.View), pView != entity.View)) { entity.View = pView; } if (request.Locked && AllowPatchValue <Scope, bool>(request, DocConstantModelName.SCOPE, pArchived, permission, nameof(request.Locked), pLocked != entity.Locked)) { entity.Archived = pArchived; } entity.SaveChanges(permission); var idsToInvalidate = new List <int>(); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityLookupTableBinding>(request, entity, pBindings, permission, nameof(request.Bindings))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityBroadcast>(request, entity, pBroadcasts, permission, nameof(request.Broadcasts))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityHelp>(request, entity, pHelp, permission, nameof(request.Help))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityComment>(request, entity, pScopedComments, permission, nameof(request.ScopedComments))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityFile>(request, entity, pScopedFiles, permission, nameof(request.ScopedFiles))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityTag>(request, entity, pScopedTags, permission, nameof(request.ScopedTags))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityTermSynonym>(request, entity, pSynonyms, permission, nameof(request.Synonyms))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityVariableRule>(request, entity, pVariableRules, permission, nameof(request.VariableRules))); idsToInvalidate.AddRange(PatchCollection <Scope, DocEntityScope, Reference, DocEntityWorkflow>(request, entity, pWorkflows, permission, nameof(request.Workflows))); if (idsToInvalidate.Any()) { idsToInvalidate.Add(entity.Id); DocCacheClient.RemoveByEntityIds(idsToInvalidate); DocCacheClient.RemoveSearch(DocConstantModelName.SCOPE); } entity.SaveChanges(permission); DocPermissionFactory.SetSelect <Scope>(currentUser, nameof(Scope), request.Select); ret = entity.ToDto(); var cacheExpires = DocResources.Metadata.GetCacheExpiration(DocConstantModelName.SCOPE); DocCacheClient.Set(key: cacheKey, value: ret, entityId: request.Id, entityType: DocConstantModelName.SCOPE, cacheExpires); return(ret); }
private Broadcast _AssignValues(Broadcast request, DocConstantPermission permission, Session session) { if (permission != DocConstantPermission.ADD && (request == null || request.Id <= 0)) { throw new HttpError(HttpStatusCode.NotFound, $"No record"); } if (permission == DocConstantPermission.ADD && !DocPermissionFactory.HasPermissionTryAdd(currentUser, "Broadcast")) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } request.Select = request.Select ?? new List <string>(); Broadcast ret = null; request = _InitAssignValues <Broadcast>(request, permission, session); //In case init assign handles create for us, return it if (permission == DocConstantPermission.ADD && request.Id > 0) { return(request); } var cacheKey = GetApiCacheKey <Broadcast>(DocConstantModelName.BROADCAST, nameof(Broadcast), request); //First, assign all the variables, do database lookups and conversions var pApp = DocEntityApp.Get(request.App?.Id, true, Execute) ?? DocEntityApp.Get(request.AppId, true, Execute); var pConfluenceId = request.ConfluenceId; var pName = request.Name; var pReprocess = request.Reprocess; var pReprocessed = request.Reprocessed; var pScopes = GetVariable <Reference>(request, nameof(request.Scopes), request.Scopes?.ToList(), request.ScopesIds?.ToList()); DocEntityLookupTable pStatus = GetLookup(DocConstantLookupTable.BROADCASTSTATUS, request.Status?.Name, request.Status?.Id); DocEntityLookupTable pType = GetLookup(DocConstantLookupTable.BROADCASTTYPE, request.Type?.Name, request.Type?.Id); var pArchived = true == request.Archived; var pLocked = request.Locked; var entity = InitEntity <DocEntityBroadcast, Broadcast>(request, permission, session); if (AllowPatchValue <Broadcast, bool>(request, DocConstantModelName.BROADCAST, pArchived, permission, nameof(request.Archived), pArchived != entity.Archived)) { entity.Archived = pArchived; } if (AllowPatchValue <Broadcast, DocEntityApp>(request, DocConstantModelName.BROADCAST, pApp, permission, nameof(request.App), pApp != entity.App)) { entity.App = pApp; } if (AllowPatchValue <Broadcast, string>(request, DocConstantModelName.BROADCAST, pConfluenceId, permission, nameof(request.ConfluenceId), pConfluenceId != entity.ConfluenceId)) { entity.ConfluenceId = pConfluenceId; } if (AllowPatchValue <Broadcast, string>(request, DocConstantModelName.BROADCAST, pName, permission, nameof(request.Name), pName != entity.Name)) { entity.Name = pName; } if (AllowPatchValue <Broadcast, bool>(request, DocConstantModelName.BROADCAST, pReprocess, permission, nameof(request.Reprocess), pReprocess != entity.Reprocess)) { entity.Reprocess = pReprocess; } if (AllowPatchValue <Broadcast, DateTime?>(request, DocConstantModelName.BROADCAST, pReprocessed, permission, nameof(request.Reprocessed), pReprocessed != entity.Reprocessed)) { entity.Reprocessed = pReprocessed; } if (AllowPatchValue <Broadcast, DocEntityLookupTable>(request, DocConstantModelName.BROADCAST, pStatus, permission, nameof(request.Status), pStatus != entity.Status)) { entity.Status = pStatus; } if (AllowPatchValue <Broadcast, DocEntityLookupTable>(request, DocConstantModelName.BROADCAST, pType, permission, nameof(request.Type), pType != entity.Type)) { entity.Type = pType; } if (request.Locked && AllowPatchValue <Broadcast, bool>(request, DocConstantModelName.BROADCAST, pArchived, permission, nameof(request.Locked), pLocked != entity.Locked)) { entity.Archived = pArchived; } entity.SaveChanges(permission); var idsToInvalidate = new List <int>(); idsToInvalidate.AddRange(PatchCollection <Broadcast, DocEntityBroadcast, Reference, DocEntityScope>(request, entity, pScopes, permission, nameof(request.Scopes))); if (idsToInvalidate.Any()) { idsToInvalidate.Add(entity.Id); DocCacheClient.RemoveByEntityIds(idsToInvalidate); DocCacheClient.RemoveSearch(DocConstantModelName.BROADCAST); } entity.SaveChanges(permission); DocPermissionFactory.SetSelect <Broadcast>(currentUser, nameof(Broadcast), request.Select); ret = entity.ToDto(); var cacheExpires = DocResources.Metadata.GetCacheExpiration(DocConstantModelName.BROADCAST); DocCacheClient.Set(key: cacheKey, value: ret, entityId: request.Id, entityType: DocConstantModelName.BROADCAST, cacheExpires); return(ret); }