/// <summary> /// The add_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Add_Click([NotNull] object sender, [NotNull] EventArgs e) { if (TopicStatusName.Text.Trim().IsNotSet() || DefaultDescription.Text.Trim().IsNotSet()) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_TOPICSTATUS_EDIT", "MSG_ENTER")); this.BindData(); } else { LegacyDb.TopicStatus_Save( this.Request.QueryString.GetFirstOrDefault("i"), this.PageContext.PageBoardID, TopicStatusName.Text.Trim(), DefaultDescription.Text.Trim()); YafBuildLink.Redirect(ForumPages.admin_topicstatus); } }
/// <summary> /// Topics the status import. /// </summary> /// <param name="boardId"> /// The board id. /// </param> /// <param name="inputStream"> /// The input stream. /// </param> /// <exception cref="Exception"> /// Import stream is not expected format. /// </exception> /// <returns> /// Returns the Number of Imported Items. /// </returns> public static int TopicStatusImport(int boardId, Stream inputStream) { var importedCount = 0; // import extensions... var dsStates = new DataSet(); dsStates.ReadXml(inputStream); if (dsStates.Tables["YafTopicStatus"] != null && dsStates.Tables["YafTopicStatus"].Columns["TopicStatusName"] != null && dsStates.Tables["YafTopicStatus"].Columns["DefaultDescription"] != null) { var topicStatusList = LegacyDb.TopicStatus_List(boardId); // import any topic status that don't exist... foreach ( var row in dsStates.Tables["YafTopicStatus"].Rows.Cast <DataRow>().Where( row => topicStatusList.Select("TopicStatusName = '{0}'".FormatWith(row["TopicStatusName"])).Length == 0)) { // add this... LegacyDb.TopicStatus_Save( null, boardId, row["TopicStatusName"].ToString(), row["DefaultDescription"].ToString()); importedCount++; } } else { throw new Exception("Import stream is not expected format."); } return(importedCount); }