Exemplo n.º 1
0
        public void CreateReview(string domainKey, string threadType, Guid itemId, string itemTitle, string message, decimal?rating, string status)
        {
            var cs          = SystemManager.GetCommentsService();
            var authorProxy = new AuthorProxy(ClaimsManager.GetCurrentUserId().ToString());

            var domainProxy = new GroupProxy("TestDomain", "TestDomainDescription", authorProxy)
            {
                Key = domainKey
            };

            cs.CreateGroup(domainProxy);

            var culture = this.GetCurrentCulture();

            var threadProxy = new ThreadProxy(itemTitle, threadType, domainKey, authorProxy)
            {
                Key = itemId.ToString() + "_" + culture + "_review", Language = culture
            };
            var thread = cs.CreateThread(threadProxy);

            DateTime dateCreated = DateTime.UtcNow.AddMinutes(5);

            var commentProxy = new CommentProxy(message, thread.Key, authorProxy, SystemManager.CurrentHttpContext.Request.UserHostAddress, rating)
            {
                Status = status, DateCreated = dateCreated
            };

            cs.CreateComment(commentProxy);
        }
Exemplo n.º 2
0
 public List <CommentProxy> GetCommentsByTaskId(int taskId)
 {
     using (var db = new DatabaseEntities())
     {
         return(CommentProxy.GetListCommentsProxy(db.Tasks.Include(t => t.Comments).FirstOrDefault(t => t.Id == taskId).Comments.ToList()));
     }
 }
Exemplo n.º 3
0
 public async Task <IActionResult> Comments(int photoId)
 {
     using (var proxy = new CommentProxy())
     {
         ViewData["comments"] = await proxy.GetAsync(photoId);
     }
     return(PartialView());
 }
Exemplo n.º 4
0
        private CommentResponse SubmitCommentInternal(CommentCreateRequest commentData, IThread thread, IAuthor author)
        {
            var cs            = SystemManager.GetCommentsService();
            var currentConfig = CommentsUtilitiesReflector.GetThreadConfigByType(thread.Type, thread.Key);

            if (currentConfig.RequiresAuthentication)
            {
                if (author.Key.IsNullOrWhitespace() || author.Key == Guid.Empty.ToString())
                {
                    throw new InvalidOperationException("Comment cannot be submitted at the moment. Please refresh the page and try again.");
                }
            }

            if (currentConfig.EnableRatings)
            {
                if (commentData.Rating == null)
                {
                    throw new InvalidOperationException("A message displayed when ratings are allowed and a comment is submitted without rating.");
                }

                if (CommentsUtilitiesReflector.GetCommentsByThreadForCurrentAuthorWithRating(thread.Key).Any())
                {
                    throw new InvalidOperationException("Only one comment with rating is allowed per user.");
                }
            }

            var authorIp     = CommentsUtilitiesReflector.GetIpAddressFromCurrentRequest();
            var commentProxy = new CommentProxy(commentData.Message, thread.Key, author, authorIp, commentData.Rating);

            commentProxy.CustomData = commentData.CustomData;

            if (currentConfig.RequiresApproval)
            {
                commentProxy.Status = StatusConstants.WaitingForApproval;
            }
            else
            {
                commentProxy.Status = StatusConstants.Published;
            }

            IComment newComment = cs.CreateComment(commentProxy);

            var result = CommentsUtilitiesReflector.GetCommentResponse(newComment, ClaimsManager.GetCurrentIdentity().IsBackendUser);

            if (commentData.Captcha != null)
            {
                CommentsUtilitiesReflector.RemoveCaptchaFromTempStorage(commentData.Captcha.Key);
            }

            ServiceUtility.DisableCache();

            return(result);
        }
Exemplo n.º 5
0
 public HttpResponseMessage UpdateComment(CommentProxy comment)
 {
     try
     {
         var c = this._commentRepository.FindById(comment.Id);
         c.Description = comment.Description;
         c.UpdatedDate = this._datetimeRepository.Now();
         this._commentRepository.Update(c);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (System.Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
     }
 }
Exemplo n.º 6
0
        public CommentProxy CreateComment(CommentProxy comment)
        {
            using (var db = new DatabaseEntities())
            {
                var com = db.Comments.Add(new Comment()
                {
                    Text       = comment.Text,
                    Owner      = comment.Owner.Id,
                    TaskId     = comment.Task.Id,
                    DatePublic = comment.DatePublic
                });

                db.SaveChanges();
                return((CommentProxy)com);
            }
        }
        public void CreateReview(string domainKey, string threadType, Guid itemId, string itemTitle, string message, decimal? rating, string status)
        {
            var cs = SystemManager.GetCommentsService();
            var authorProxy = new AuthorProxy(ClaimsManager.GetCurrentUserId().ToString());

            var domainProxy = new GroupProxy("TestDomain", "TestDomainDescription", authorProxy) { Key = domainKey };
            cs.CreateGroup(domainProxy);

            var threadProxy = new ThreadProxy(itemTitle, threadType, domainKey, authorProxy) { Key = itemId.ToString() + "_en_review", Language = "en" };
            var thread = cs.CreateThread(threadProxy);

            DateTime dateCreated = DateTime.UtcNow.AddMinutes(5);

            var commentProxy = new CommentProxy(message, thread.Key, authorProxy, SystemManager.CurrentHttpContext.Request.UserHostAddress, rating)
                                { Status = status, DateCreated = dateCreated };
            cs.CreateComment(commentProxy);
        }
Exemplo n.º 8
0
        public static void CreateBlogPostComment(Guid blogPostId, GenericPostComment comment)
        {
            BlogPost blogPost = SFBlogsManager.GetBlogPost(blogPostId);

            var cs        = SystemManager.GetCommentsService();
            var language  = Thread.CurrentThread.CurrentUICulture.Name;
            var threadKey = ControlUtilities.GetLocalizedKey(blogPostId, language);

            var commentAuthor = new AuthorProxy(comment.Author, comment.AuthorEmail);

            EnsureBlogPostThreadExists(threadKey, commentAuthor, blogPost.Title, SFBlogsManager, language, cs);

            var commentProxy = new CommentProxy(comment.Content, threadKey, commentAuthor, comment.AuthorIP);

            commentProxy.Status = StatusConstants.Published;

            var newComment = cs.CreateComment(commentProxy);

            newComment.DateCreated  = comment.CommentDateGMT;
            newComment.LastModified = comment.CommentDateGMT;

            cs.UpdateComment(newComment);
        }
Exemplo n.º 9
0
 public CommentProxy CreateComment(CommentProxy comment)
 {
     return(commentControl.CreateComment(comment));
 }
Exemplo n.º 10
0
        public static void CreateBlogPostComment(Guid blogPostId, GenericPostComment comment)
        {
            BlogPost blogPost = SFBlogsManager.GetBlogPost(blogPostId);

            var cs = SystemManager.GetCommentsService();
            var language = Thread.CurrentThread.CurrentUICulture.Name;
            var threadKey = ControlUtilities.GetLocalizedKey(blogPostId, language);

            var commentAuthor = new AuthorProxy(comment.Author, comment.AuthorEmail);

            EnsureBlogPostThreadExists(threadKey, commentAuthor, blogPost.Title, SFBlogsManager, language, cs);

            var commentProxy = new CommentProxy(comment.Content, threadKey, commentAuthor, comment.AuthorIP);

            commentProxy.Status = StatusConstants.Published;

            var newComment = cs.CreateComment(commentProxy);

            newComment.DateCreated = comment.CommentDateGMT;
            newComment.LastModified = comment.CommentDateGMT;

            cs.UpdateComment(newComment);
        }
Exemplo n.º 11
0
        private CommentResponse SubmitCommentInternal(CommentCreateRequest commentData, IThread thread, IAuthor author)
        {
            var cs = SystemManager.GetCommentsService();
            var currentConfig = CommentsUtilitiesReflector.GetThreadConfigByType(thread.Type, thread.Key);

            if (currentConfig.RequiresAuthentication)
            {
                if (author.Key.IsNullOrWhitespace() || author.Key == Guid.Empty.ToString())
                {
                    throw new InvalidOperationException("Comment cannot be submitted at the moment. Please refresh the page and try again.");
                }
            }

            if (currentConfig.EnableRatings)
            {
                if (commentData.Rating == null)
                {
                    throw new InvalidOperationException("A message displayed when ratings are allowed and a comment is submitted without rating.");
                }

                if (CommentsUtilitiesReflector.GetCommentsByThreadForCurrentAuthorWithRating(thread.Key).Any())
                {
                    throw new InvalidOperationException("Only one comment with rating is allowed per user.");
                }
            }

            var authorIp = CommentsUtilitiesReflector.GetIpAddressFromCurrentRequest();
            var commentProxy = new CommentProxy(commentData.Message, thread.Key, author, authorIp, commentData.Rating);
            commentProxy.CustomData = commentData.CustomData;

            if (currentConfig.RequiresApproval)
                commentProxy.Status = StatusConstants.WaitingForApproval;
            else
                commentProxy.Status = StatusConstants.Published;

            IComment newComment = cs.CreateComment(commentProxy);

            var result = CommentsUtilitiesReflector.GetCommentResponse(newComment, ClaimsManager.GetCurrentIdentity().IsBackendUser);

            ServiceUtility.DisableCache();

            return result;
        }
Exemplo n.º 12
0
        public CommentProxy CreateComment(int accountId, CommentProxy comment)
        {
            var comm = dataAccess.CreateComment(comment);

            return(comm);
        }