当前位置: 首页>>代码示例>>C#>>正文


C# ForumPost.Save方法代码示例

本文整理汇总了C#中ForumPost.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ForumPost.Save方法的具体用法?C# ForumPost.Save怎么用?C# ForumPost.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ForumPost的用法示例。


在下文中一共展示了ForumPost.Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveDetails

    private int SaveDetails( ForumPost item )
    {
        int rowsAffected = 0;
        try
        {
            Session["CurrentObject"] = item.Save();
            rowsAffected = 1;
        }
        catch (Csla.Validation.ValidationException ex)
        {
            System.Text.StringBuilder message = new System.Text.StringBuilder();
            message.AppendFormat( "{0}<br/>", ex.Message );
            if (item.BrokenRulesCollection.Count == 1)
                message.AppendFormat( "* {0}: {1}", item.BrokenRulesCollection[0].Property, item.BrokenRulesCollection[0].Description );
            else
                foreach (Csla.Validation.BrokenRule rule in item.BrokenRulesCollection)
                    message.AppendFormat( "* {0}: {1}<br/>", rule.Property, rule.Description );

            PostError.Visible = true;
            PostError.Text = message.ToString();
            rowsAffected = 0;
        }
        catch (Csla.DataPortalException ex)
        {
            PostError.Visible = true;
            PostError.Text = ex.BusinessException.Message;
            rowsAffected = 0;
        }
        catch (Exception ex)
        {
            PostError.Visible = true;
            PostError.Text = ex.Message;
            rowsAffected = 0;
        }
        return rowsAffected;
    }
开发者ID:TertiumQuid,项目名称:Aphelion-Trigger,代码行数:36,代码来源:ForumTopic.aspx.cs

示例2: SaveDetails

    private int SaveDetails( ForumPost item )
    {
        int rowsAffected = 0;

        // before adding the post, we have to add a new topic
        ForumTopic topic = ForumTopic.NewForumTopic();
        try
        {
            int boardId = 0;
            try { boardId = Int32.Parse( Request.QueryString["ID"] ); } catch { Response.Redirect( "ForumBoards.aspx"); }

            topic.BoardID = boardId;
            topic.Title = item.Subject;
            topic.Sticky = Sticky.Checked;
            topic.Locked = Locked.Checked;

            if (item.IsValid) topic.Save();

            // now we can assign the new topic's id to the post
            item.TopicID = topic.ID;

            item.UserID = User.ID;
            item.Save();
            rowsAffected = 1;
        }
        catch (Csla.Validation.ValidationException ex)
        {
            System.Text.StringBuilder message = new System.Text.StringBuilder();
            message.AppendFormat( "{0}<br/>", ex.Message );
            if (item.BrokenRulesCollection.Count == 1)
                message.AppendFormat( "* {0}: {1}", item.BrokenRulesCollection[0].Property, item.BrokenRulesCollection[0].Description );
            else if (item.BrokenRulesCollection.Count > 1)
                foreach (Csla.Validation.BrokenRule rule in item.BrokenRulesCollection)
                    message.AppendFormat( "* {0}: {1}<br/>", rule.Property, rule.Description );

            if (topic.BrokenRulesCollection.Count == 1)
                message.AppendFormat( "* {0}: {1}", topic.BrokenRulesCollection[0].Property, topic.BrokenRulesCollection[0].Description );
            else if (topic.BrokenRulesCollection.Count > 1)
                foreach (Csla.Validation.BrokenRule rule in topic.BrokenRulesCollection)
                    message.AppendFormat( "* {0}: {1}<br/>", rule.Property, rule.Description );

            PostError.Visible = true;
            PostError.Text = message.ToString();
            rowsAffected = 0;
        }
        catch (Csla.DataPortalException ex)
        {
            PostError.Visible = true;
            PostError.Text = ex.BusinessException.Message;
            rowsAffected = 0;
        }
        catch (Exception ex)
        {
            PostError.Visible = true;
            PostError.Text = ex.Message;
            rowsAffected = 0;
        }
        return rowsAffected;
    }
开发者ID:TertiumQuid,项目名称:Aphelion-Trigger,代码行数:59,代码来源:ForumBoard.aspx.cs


注:本文中的ForumPost.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。