protected override void ExecuteWorkImplementation() { foreach (var bookType in BookTypeHelper.GetBookTypeEnumsWithCategories()) { var category = m_categoryRepository.GetCategoryByExternalId((short)bookType); var forum = m_forumRepository.GetForumByExternalCategoryIdAndCategory(m_oldCategory.Id, category.CategoryID); forum.Name = m_updatedCategory.Description; if (m_oldCategory.ParentCategoryId != m_updatedCategory.ParentCategoryId) { forum.ParentForum = m_updatedCategory.ParentCategoryId == null ? null : m_forumRepository.GetForumByExternalCategoryIdAndCategory((int)m_updatedCategory.ParentCategoryId, category.CategoryID); } m_forumRepository.Update(forum); } }
protected override void ExecuteWorkImplementation() { foreach (var bookType in BookTypeHelper.GetBookTypeEnumsWithCategories()) { var category = m_categoryRepository.GetCategoryByExternalId((short)bookType); Forum parentForum = null; if (m_category.ParentCategoryId != null) { parentForum = m_forumRepository.GetForumByExternalCategoryIdAndCategory((int)m_category.ParentCategoryId, category.CategoryID); } var forum = new Forum(m_category.Description, category, (short)ForumTypeEnum.SubCategory) { ExternalId = m_category.Id, ParentForum = parentForum }; m_forumRepository.Create(forum); m_forumAccessSubwork.SetAdminAccessToForumForAdminGroup(forum); } }
protected override void ExecuteWorkImplementation() { foreach (var bookType in BookTypeHelper.GetBookTypeEnumsWithCategories()) { var category = m_categoryRepository.GetCategoryByExternalId((short)bookType); var forum = m_forumRepository.GetForumByExternalCategoryIdAndCategory(m_categoryId, category.CategoryID); if (forum == null) { throw new MainServiceException(MainServiceErrorCode.EntityNotFound, "The entity was not found", HttpStatusCode.NotFound); } if (forum.Forums.Count > 0) { throw new MainServiceException(MainServiceErrorCode.CategoryHasSubCategories, "Category has some sub-categories", HttpStatusCode.BadRequest); } var forumAccesses = m_forumRepository.GetAllAccessesForForum(forum.ForumID); m_forumRepository.DeleteAll(forumAccesses); m_forumRepository.Delete(forum); } }