コード例 #1
0
        public Post InsertPost(int threadID, string content, out Thread thread)
        {
            var currentUser = System.Threading.Thread.CurrentPrincipal.Identity.Name;

            var post = new Post
            {
                ThreadID = threadID,
                Content = content,
                Created = DateTime.UtcNow,
                CreatedBy = currentUser
            };
            Posts.Add(post);

            thread = Threads.Find(threadID);
            thread.LastPost = DateTime.UtcNow;
            thread.LastPostBy = currentUser;
            thread.PostCount++;

            SaveChanges();

            return post;
        }
コード例 #2
0
 public static void PostAdded(Post post)
 {
     var hubContext = GlobalHost.ConnectionManager.GetHubContext<PostHub>();
     hubContext.Clients.Group(ThreadHub.GetGroupNameForThread(post.ThreadID)).postAdded(post);
 }