コード例 #1
0
        public async Task <IActionResult> Page(string id)
        {
            KirjaPage page = null;

            if (!string.IsNullOrEmpty(id))
            {
                page = await _pageDbAccess.GetPageById(id);
            }
            else
            {
                GoNorthProject project = await _projectDbAccess.GetDefaultProject();

                page = await _pageDbAccess.GetDefaultPageForProject(project.Id);

                if (page == null)
                {
                    page           = new KirjaPage();
                    page.IsDefault = true;
                    page.ProjectId = project.Id;
                    page.Name      = _localizer["DefaultPageName"];
                    page.Content   = _localizer["DefaultPageContent"];

                    _pageParserService.ParsePage(page);

                    page = await _pageDbAccess.CreatePage(page);
                }
            }
            return(Ok(page));
        }
コード例 #2
0
        /// <summary>
        /// Checks if a project is empty
        /// </summary>
        /// <param name="project">Project to check</param>
        /// <returns>True if the project is empty, else false</returns>
        private async Task <bool> IsProjectEmpty(GoNorthProject project)
        {
            int rootKortistoFolderCount = await _kortistoFolderDbAccess.GetRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootKortistoFolderCount > 0)
            {
                return(false);
            }

            int rootNpcCount = await _npcDbAccess.GetFlexFieldObjectsInRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootNpcCount > 0)
            {
                return(false);
            }

            int rootStyrFolderCount = await _styrFolderDbAccess.GetRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootStyrFolderCount > 0)
            {
                return(false);
            }

            int rootItemCount = await _itemDbAccess.GetFlexFieldObjectsInRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootItemCount > 0)
            {
                return(false);
            }

            int rootEvneFolderCount = await _evneFolderDbAccess.GetRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootEvneFolderCount > 0)
            {
                return(false);
            }

            int rootSkillCount = await _evneSkillDbAccess.GetFlexFieldObjectsInRootFolderCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (rootSkillCount > 0)
            {
                return(false);
            }

            int kirjaPageCount = await _kirjaPageDbAccess.SearchPagesCount(project.Id, string.Empty, string.Empty, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (kirjaPageCount > 1)
            {
                return(false);
            }
            else if (kirjaPageCount == 1)
            {
                KirjaPage defaultPage = await _kirjaPageDbAccess.GetDefaultPageForProject(project.Id);

                if (defaultPage == null)
                {
                    return(false);
                }
            }

            int chapterDetailCount = await _chapterDetailDbAccess.GetChapterDetailsByProjectIdCount(project.Id);

            if (chapterDetailCount > 0)
            {
                return(false);
            }

            int questCount = await _questDbAccess.GetQuestsByProjectIdCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (questCount > 0)
            {
                return(false);
            }

            List <KartaMap> maps = await _mapDbAccess.GetAllProjectMaps(project.Id);

            if (maps != null && maps.Count > 0)
            {
                return(false);
            }

            int taskBoardCount = await _taskBoardDbAccess.GetOpenTaskBoardCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            taskBoardCount += await _taskBoardDbAccess.GetClosedTaskBoardCount(project.Id, CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);

            if (taskBoardCount > 0)
            {
                return(false);
            }

            return(true);
        }