/// <summary> /// Fills the task numbers for a board /// </summary> /// <param name="taskBoard">Task board to fill</param> /// <returns>Task</returns> private async Task FillTaskNumbersForBoard(TaskBoard taskBoard) { if (taskBoard.TaskGroups == null) { return; } foreach (TaskGroup curGroup in taskBoard.TaskGroups) { await FillTaskNumbersForTaskGroup(taskBoard.ProjectId, curGroup); } await _taskBoardDbAccess.UpdateTaskBoard(taskBoard); }
public async Task <IActionResult> UpdateTaskBoard(string id, [FromBody] TaskBoard board) { // Validate Data if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(board.Name)) { return(StatusCode((int)HttpStatusCode.BadRequest)); } // Updates a Task Board TaskBoard updatedTaskBoard = await _taskBoardDbAccess.GetTaskBoardById(id); if (updatedTaskBoard == null) { return(StatusCode((int)HttpStatusCode.NotFound)); } updatedTaskBoard.Name = board.Name; updatedTaskBoard.PlannedStart = board.PlannedStart; updatedTaskBoard.PlannedEnd = board.PlannedEnd; await this.SetModifiedData(_userManager, updatedTaskBoard); try { await _taskBoardDbAccess.UpdateTaskBoard(updatedTaskBoard); } catch (Exception ex) { _logger.LogError(ex, "Could not update task board."); return(StatusCode((int)HttpStatusCode.InternalServerError)); } // Add Timeline entry await _timelineService.AddTimelineEntry(TimelineEvent.TaskBoardUpdated, updatedTaskBoard.Id, updatedTaskBoard.Name); return(Ok(updatedTaskBoard.Id)); }
/// <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); } 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); } 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); } 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); } 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); } 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); } 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); } 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 <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); } 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); } }