Beispiel #1
0
        public List <BookWithCategoriesContract> GetBooksByTypeForUser(BookTypeEnumContract bookType, int start, int count)
        {
            count = PagingHelper.GetCount(count);
            var projectType     = m_portalTypeProvider.GetDefaultProjectType();
            var projectTypeEnum = m_mapper.Map <ProjectTypeEnum>(projectType);
            var bookTypeEnum    = m_mapper.Map <BookTypeEnum>(bookType);
            var user            = m_authenticationManager.GetCurrentUser(true);
            var dbMetadataList  = m_metadataRepository.InvokeUnitOfWork(x => x.GetMetadataByBookTypeWithCategories(bookTypeEnum, user.Id, projectTypeEnum, start, count));
            var resultList      = m_mapper.Map <List <BookWithCategoriesContract> >(dbMetadataList);

            return(resultList);
        }
        public void ProcessSessionAsImport(string sessionId, long?projectId, string comment)
        {
            var userId = m_authenticationManager.GetCurrentUserId();
            var allAutoImportPermissions = m_permissionManager.GetAutoImportSpecialPermissions();
            var projectType         = m_portalTypeProvider.GetDefaultProjectType();
            var fulltextStorageType = m_fulltextStorageProvider.GetStorageType((ProjectTypeEnum)projectType);

            ImportResultContract importResult;

            using (var client = m_communicationProvider.GetFileProcessingClient())
            {
                try
                {
                    importResult = client.ProcessSession(sessionId, projectId, userId, comment, (ProjectTypeContract)projectType, (FulltextStoreTypeContract)fulltextStorageType, allAutoImportPermissions);
                    if (!importResult.Success)
                    {
                        throw new MainServiceException(MainServiceErrorCode.ImportFailed, "Import failed");
                    }
                }
                catch (FileProcessingImportFailedException exception)
                {
                    throw new MainServiceException(MainServiceErrorCode.ImportFailedWithError, $"Import failed with error: {exception.InnerException?.Message}", descriptionParams: exception.InnerException?.Message);
                }
            }

            if (projectType == DataContracts.Contracts.Type.ProjectTypeContract.Community)
            {
                try
                {
                    m_forumSiteManager.CreateOrUpdateForums(importResult.ProjectId);
                }
                catch (ForumException e)
                {
                    throw new MainServiceException(MainServiceErrorCode.ImportSucceedForumFailed,
                                                   $"Import succeeded. Forum creation failed. {e.Message}", HttpStatusCode.BadRequest, new object[] { e.Code });
                }
            }
        }