Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="post"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public PostComment CreateComment(Post post, string message)
        {
            var comment = postRepo.CreatePostComment(post,
                new PostComment() { ID = Guid.NewGuid(), Message = message, PostID = post.ID, UserID = CfIdentity.UserID, Utc = DateTime.UtcNow });

            //-- Log replies to partner calls!
            if (post.TypeID == (int)PostType.PartnerCall) { new cf.Services.PartnerCallService().LogPartnerCallCommentReply(post, comment); }

            //-- Send off Alerts!!
            new AlertsService().EnqueCommentWorkItem(CfIdentity.UserID, post.ID, comment.Message);

            return comment;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static string BindContentForMobile(Post post)
        {
            string content = string.Empty;

            var postMgr = PostTemplateLibrary.Get(post.TemplateKey);

            if (postMgr != null)
            {
                dynamic obj = Serializer.Deserialize(post.TemplateData, typeof(object));
                content = postMgr.RenderMobile(obj);// post.TemplateData;
            }
            else
            {
                //-- Trace failed render?
                content = "Failed to render content for template " + post.TemplateKey;
            }

            return content.Replace("&#39;","'");
        }
        /// <summary>
        /// Log when someone responds to a partner call by public comment
        /// </summary>
        /// <param name="post"></param>
        /// <param name="postComment"></param>
        public void LogPartnerCallCommentReply(Post post, PostComment postComment)
        {
            //-- Can't reply to yourself.
            if (post.UserID != postComment.UserID)
            {
                var pc = pcRepo.GetByID(post.ID);

                var pcr = new PartnerCallReply() { ID = Guid.NewGuid(), Message = postComment.Message, PartnerCallID = post.ID,
                     TypeID = (byte)PartnerCallReplyType.Comment, Utc = DateTime.UtcNow, UserID = postComment.UserID };

                AddPartnerCallSubscriptionWorkItemReply(pc, pcr);
            }
        }
Esempio n. 4
0
        public void DeletePost(Post obj)
        {
            var currentUserID = CfIdentity.UserID;
            var userHasRightsToDeletePost = (currentUserID == obj.UserID) || CfPrincipal.IsGod();
            if (!userHasRightsToDeletePost) { throw new AccessViolationException("Delete Post: Cannot delete this post, it does not belong to the current user."); }

            postRepo.Delete(obj.ID);
        }
Esempio n. 5
0
 /// <summary>
 /// General purpose delete
 /// </summary>
 /// <param name="post"></param>
 private void DeleteTypedPost(Post post)
 {
     if (post != null)
     {
         PostTemplateLibrary.Get(post.TemplateKey).DeletePost(post);
     }
 }
Esempio n. 6
0
 public Post UpdatePost(Post obj)
 {
     return postRepo.Update(obj);
 }