private void btnSave_ServerClick(object sender, System.EventArgs e) { if (Page.IsValid) { int?supportQueueID = null; int selectedSupportQueueID = Convert.ToInt32(cbxSupportQueues.SelectedItem.Value); if (selectedSupportQueueID > 0) { supportQueueID = selectedSupportQueueID; } string newThreadWelcomeText = null; string newThreadWelcomeTextAsHTML = null; if (tbxNewThreadWelcomeText.Text.Trim().Length > 0) { // has specified welcome text, convert to HTML newThreadWelcomeText = tbxNewThreadWelcomeText.Text.Trim(); string parserLog, textAsXML; bool errorsOccured; newThreadWelcomeTextAsHTML = TextParser.TransformUBBMessageStringToHTML(newThreadWelcomeText, ApplicationAdapter.GetParserData(), out parserLog, out errorsOccured, out textAsXML); } // store the data as a new forum. int forumID = ForumManager.CreateNewForum(HnDGeneralUtils.TryConvertToInt(cbxSections.SelectedItem.Value), tbxForumName.Value, tbxForumDescription.Text, chkHasRSSFeed.Checked, supportQueueID, HnDGeneralUtils.TryConvertToInt(cbxThreadListInterval.SelectedValue), HnDGeneralUtils.TryConvertToShort(tbxOrderNo.Text), HnDGeneralUtils.TryConvertToInt(tbxMaxAttachmentSize.Text), HnDGeneralUtils.TryConvertToShort(tbxMaxNoOfAttachmentsPerMessage.Text), newThreadWelcomeText, newThreadWelcomeTextAsHTML); // done for now, redirect to self Response.Redirect("AddForum.aspx", true); } }
public int?CreateOrUpdateForums(long projectId, short[] bookTypeIds = null) { if (m_forumOptions.IsEnabled == false) { return(null); } var work = new GetProjectWork(m_projectRepository, m_metadataRepository, projectId, true, true, false, true); var project = work.Execute(); if (project == null) { throw new ForumException(MainServiceErrorCode.ProjectNotExist, "The project does not exist."); } var projectDetailContract = m_mapper.Map <ProjectDetailContract>(project); projectDetailContract.PageCount = work.GetPageCount(); if (bookTypeIds == null && project.LatestPublishedSnapshot != null) { bookTypeIds = project.LatestPublishedSnapshot.BookTypes.Select(x => (short)x.Type).ToArray(); } if (project.ForumId != null) { m_forumManager.UpdateForum(projectDetailContract, bookTypeIds); } var forum = m_forumManager.GetForumByExternalId(project.Id); if (forum == null) { //Create forum var forumId = m_forumManager.CreateNewForum(projectDetailContract, bookTypeIds); new SetForumIdToProjectWork(m_projectRepository, projectId, forumId).Execute(); return(forumId); } //Forum is created, but not connect with project -> set ForumId to Project new SetForumIdToProjectWork(m_projectRepository, projectId, forum.ForumID).Execute(); return(forum.ForumID); }