示例#1
0
        /// <summary>
        /// Deletes the modified data for the user
        /// </summary>
        /// <param name="user">User</param>
        /// <returns>Task</returns>
        private async Task DeleteModifiedData(GoNorthUser user)
        {
            List <AikaQuest> quests = await _questDbAccess.GetQuestsByModifiedUser(user.Id);

            foreach (AikaQuest curQuest in quests)
            {
                curQuest.ModifiedBy = Guid.Empty.ToString();
                curQuest.ModifiedOn = DateTimeOffset.UtcNow;
                await _questDbAccess.UpdateQuest(curQuest);
            }

            await _questDbAccess.ResetRecycleBinQuestByModifiedUser(user.Id);

            await _questImplementationSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            List <AikaChapterDetail> chapterDetail = await _chapterDetailDbAccess.GetChapterDetailsByModifiedUser(user.Id);

            foreach (AikaChapterDetail curChapterDetail in chapterDetail)
            {
                curChapterDetail.ModifiedBy = Guid.Empty.ToString();
                curChapterDetail.ModifiedOn = DateTimeOffset.UtcNow;
                await _chapterDetailDbAccess.UpdateChapterDetail(curChapterDetail);
            }

            await _chapterDetailDbAccess.ResetRecycleBinChapterDetailsByModifiedUser(user.Id);

            List <AikaChapterOverview> chapterOverview = await _chapterOverviewDbAccess.GetChapterOverviewByModifiedUser(user.Id);

            foreach (AikaChapterOverview curOverview in chapterOverview)
            {
                curOverview.ModifiedBy = Guid.Empty.ToString();
                curOverview.ModifiedOn = DateTimeOffset.UtcNow;
                await _chapterOverviewDbAccess.UpdateChapterOverview(curOverview);
            }

            await _chapterOverviewDbAccess.ResetRecycleBinChapterOverviewByModifiedUser(user.Id);

            List <EvneSkill> skills = await _skillDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (EvneSkill curSkill in skills)
            {
                curSkill.ModifiedBy = Guid.Empty.ToString();
                curSkill.ModifiedOn = DateTimeOffset.UtcNow;
                await _skillDbAccess.UpdateFlexFieldObject(curSkill);
            }

            await _skillDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            await _skillImplementationSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            await _skillImportFieldValuesLogDbAccess.ResetImportLogsByModifiedUser(user.Id);

            List <EvneSkill> skillTemplates = await _skillTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (EvneSkill curSkill in skillTemplates)
            {
                curSkill.ModifiedBy = Guid.Empty.ToString();
                curSkill.ModifiedOn = DateTimeOffset.UtcNow;
                await _skillTemplateDbAccess.UpdateFlexFieldObject(curSkill);
            }

            await _skillTemplateDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            List <KortistoNpc> npcs = await _npcDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (KortistoNpc curNpc in npcs)
            {
                curNpc.ModifiedBy = Guid.Empty.ToString();
                curNpc.ModifiedOn = DateTimeOffset.UtcNow;
                await _npcDbAccess.UpdateFlexFieldObject(curNpc);
            }

            await _npcDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            await _npcImplementationSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            await _npcImportFieldValuesLogDbAccess.ResetImportLogsByModifiedUser(user.Id);

            List <KortistoNpc> npcTemplates = await _npcTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (KortistoNpc curNpc in npcTemplates)
            {
                curNpc.ModifiedBy = Guid.Empty.ToString();
                curNpc.ModifiedOn = DateTimeOffset.UtcNow;
                await _npcTemplateDbAccess.UpdateFlexFieldObject(curNpc);
            }

            await _npcTemplateDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            List <StyrItem> items = await _itemDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (StyrItem curItem in items)
            {
                curItem.ModifiedBy = Guid.Empty.ToString();
                curItem.ModifiedOn = DateTimeOffset.UtcNow;
                await _itemDbAccess.UpdateFlexFieldObject(curItem);
            }

            await _itemDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            await _itemImplementationSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            await _itemImportFieldValuesLogDbAccess.ResetImportLogsByModifiedUser(user.Id);

            List <StyrItem> itemTemplates = await _itemTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (StyrItem curItem in itemTemplates)
            {
                curItem.ModifiedBy = Guid.Empty.ToString();
                curItem.ModifiedOn = DateTimeOffset.UtcNow;
                await _itemTemplateDbAccess.UpdateFlexFieldObject(curItem);
            }

            await _itemTemplateDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            List <ExportTemplate> exportTemplates = await _exportTemplateDbAccess.GetExportTemplatesByModifiedUser(user.Id);

            foreach (ExportTemplate curTemplate in exportTemplates)
            {
                curTemplate.ModifiedBy = Guid.Empty.ToString();
                curTemplate.ModifiedOn = DateTimeOffset.UtcNow;
                await _exportTemplateDbAccess.UpdateTemplate(curTemplate);
            }

            await _exportTemplateDbAccess.ResetRecycleBinExportTemplatesByModifiedUser(user.Id);

            List <IncludeExportTemplate> includeExportTemplates = await _includeExportTemplateDbAccess.GetIncludeTemplatesByModifiedUser(user.Id);

            foreach (IncludeExportTemplate curTemplate in includeExportTemplates)
            {
                curTemplate.ModifiedBy = Guid.Empty.ToString();
                curTemplate.ModifiedOn = DateTimeOffset.UtcNow;
                await _includeExportTemplateDbAccess.UpdateIncludeTemplate(curTemplate);
            }

            await _includeExportTemplateDbAccess.ResetIncludeRecycleBinExportTemplatesByModifiedUser(user.Id);

            List <ObjectExportSnippet> objectExportSnippets = await _objectExportSnippetDbAccess.GetExportSnippetByModifiedUser(user.Id);

            foreach (ObjectExportSnippet curExportSnippet in objectExportSnippets)
            {
                curExportSnippet.ModifiedBy = Guid.Empty.ToString();
                curExportSnippet.ModifiedOn = DateTimeOffset.UtcNow;
                await _objectExportSnippetDbAccess.UpdateExportSnippet(curExportSnippet);
            }

            List <KartaMap> maps = await _mapDbAccess.GetMapsByModifiedUser(user.Id);

            foreach (KartaMap curMap in maps)
            {
                curMap.ModifiedBy = Guid.Empty.ToString();
                curMap.ModifiedOn = DateTimeOffset.UtcNow;
                await _mapDbAccess.UpdateMap(curMap);
            }

            List <KirjaPage> pages = await _pageDbAccess.GetPagesByModifiedUser(user.Id);

            foreach (KirjaPage curPage in pages)
            {
                curPage.ModifiedBy = Guid.Empty.ToString();
                curPage.ModifiedOn = DateTimeOffset.UtcNow;
                await _pageDbAccess.UpdatePage(curPage);
            }

            List <KirjaPageVersion> pageVersions = await _pageVersionDbAccess.GetPageVersionsByModifiedUser(user.Id);

            foreach (KirjaPageVersion curVersion in pageVersions)
            {
                curVersion.ModifiedBy = Guid.Empty.ToString();
                curVersion.ModifiedOn = DateTimeOffset.UtcNow;
                await _pageVersionDbAccess.UpdatePageVersion(curVersion);
            }

            List <KirjaPageReview> pageReview = await _pageReviewDbAccess.GetReviewsByModifiedUser(user.Id);

            foreach (KirjaPageReview curPageReview in pageReview)
            {
                curPageReview.ModifiedBy = Guid.Empty.ToString();
                curPageReview.ModifiedOn = DateTimeOffset.UtcNow;
                await _pageReviewDbAccess.UpdatePageReview(curPageReview);
            }

            List <TaleDialog> dialogs = await _taleDbAccess.GetDialogsByModifiedUser(user.Id);

            foreach (TaleDialog curDialog in dialogs)
            {
                curDialog.ModifiedBy = Guid.Empty.ToString();
                curDialog.ModifiedOn = DateTimeOffset.UtcNow;
                await _taleDbAccess.UpdateDialog(curDialog);
            }

            await _taleDbAccess.ResetRecycleBinFlexFieldObjectsByModifiedUser(user.Id);

            await _taleImplementationSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            await _stateMachineDbAccess.ResetStateMachinesByModifiedUser(user.Id);

            await _stateMachineSnapshotDbAccess.ResetSnapshotsByModifiedUser(user.Id);

            List <JsonConfigEntry> jsonConfigEntries = await _projectConfigDbAccess.GetJsonConfigEntriesByModifiedUser(user.Id);

            foreach (JsonConfigEntry curConfig in jsonConfigEntries)
            {
                curConfig.ModifiedBy = Guid.Empty.ToString();
                curConfig.ModifiedOn = DateTimeOffset.UtcNow;
                await _projectConfigDbAccess.UpdateJsonConfig(curConfig);
            }

            List <MiscProjectConfig> miscConfigEntries = await _projectConfigDbAccess.GetMiscConfigEntriesByModifiedUser(user.Id);

            foreach (MiscProjectConfig curMiscConfig in miscConfigEntries)
            {
                curMiscConfig.ModifiedBy = Guid.Empty.ToString();
                curMiscConfig.ModifiedOn = DateTimeOffset.UtcNow;
                await _projectConfigDbAccess.UpdateMiscConfig(curMiscConfig);
            }

            List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetTaskBoardsByModifiedUser(user.Id);

            foreach (TaskBoard curBoard in taskBoards)
            {
                if (curBoard.ModifiedBy == user.Id)
                {
                    curBoard.ModifiedBy = Guid.Empty.ToString();
                    curBoard.ModifiedOn = DateTimeOffset.UtcNow;
                }

                List <TaskGroup> modifiedGroups = curBoard.TaskGroups.Where(t => t.ModifiedBy == user.Id).ToList();
                foreach (TaskGroup curTaskGroup in modifiedGroups)
                {
                    curTaskGroup.ModifiedBy = Guid.Empty.ToString();
                    curTaskGroup.ModifiedOn = DateTimeOffset.UtcNow;
                }

                List <GoNorthTask> tasks = curBoard.TaskGroups.SelectMany(p => p.Tasks.Where(t => t.ModifiedBy == user.Id)).ToList();
                if (tasks.Count > 0)
                {
                    foreach (GoNorthTask curTask in tasks)
                    {
                        curTask.ModifiedBy = Guid.Empty.ToString();
                        curTask.ModifiedOn = DateTimeOffset.UtcNow;
                    }
                }

                await _taskBoardDbAccess.UpdateTaskBoard(curBoard);
            }

            List <GoNorthTaskType> taskGroupTypes = await _taskGroupTypeDbAccess.GetTaskTypesByModifiedUser(user.Id);

            foreach (GoNorthTaskType curType in taskGroupTypes)
            {
                curType.ModifiedBy = Guid.Empty.ToString();
                curType.ModifiedOn = DateTimeOffset.UtcNow;
                await _taskGroupTypeDbAccess.UpdateTaskType(curType);
            }

            List <GoNorthTaskType> taskTypes = await _taskTypeDbAccess.GetTaskTypesByModifiedUser(user.Id);

            foreach (GoNorthTaskType curType in taskTypes)
            {
                curType.ModifiedBy = Guid.Empty.ToString();
                curType.ModifiedOn = DateTimeOffset.UtcNow;
                await _taskTypeDbAccess.UpdateTaskType(curType);
            }

            await _projectDbAccess.DeleteUserSelectedProject(user.Id);
        }