コード例 #1
0
 protected void postsSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     //insert topic subscription if user preference is set
     if (FudgeUser.IsOptionSet(Fudge.Framework.Database.User.UserOptions.AutomaticallySubscribeToMyTopics))
     {
         FudgeUser.SubscribeForReplies((e.Result as Post).TopicId);
     }
     //redirect
     Response.Redirect("/Community/Forum/Topic/" + Request.QueryString["id"]);
 }
コード例 #2
0
    void Posts_ItemInserted(object sender, ListViewInsertedEventArgs e)
    {
        if (!Topic.User.IsLoggedOn)
        {
            //only subscribe once
            if (FudgeUser.IsOptionSet(FudgeDatabase.User.UserOptions.AutomaticallySubscribeToTopicsIReplyTo) &&
                !FudgeUser.IsSubscribedTo(Topic.TopicId))
            {
                //subscribe
                FudgeUser.SubscribeForReplies(Topic.TopicId);
            }

            var subscriptions = from s in db.TopicSubscriptions
                                where s.TopicId == Topic.TopicId && s.UserId != FudgeUser.UserId && s.UserId != Topic.UserId
                                select s;

            foreach (var s in subscriptions)
            {
                Email.NotifyNotMyTopicReply.Send(s.User, FudgeUser.FirstName + " replied to " + Topic.Title,
                                                 FudgeUser.FirstName, Topic.Title, Topic.TopicId);
            }
        }

        if (!Topic.User.IsLoggedOn && Topic.User.IsSubscribedTo(Topic.TopicId))
        {
            //send notification to the topic owner
            Notification.Notify(Notification.TopicReply(Topic.TopicId));

            //send and email
            Email.NotifyTopicReply.Send(Topic.User, FudgeUser.FirstName + " replied to your post!",
                                        FudgeUser.FirstName, Topic.Title, Topic.TopicId);
        }
        //go to the last page
        int lastPage = (postsPager.TotalRowCount / postsPager.PageSize) + 1;

        postsPager.CurrentPage = lastPage;
    }