示例#1
0
        public async Task <IActionResult> AddCommentAsync(string body, string articleId)
        {
            Comment result  = null;
            string  message = "";

            if (User.Identity.IsAuthenticated)
            {
                var user = await _userManager.GetUserAsync(User);

                result = CommentCore.AddComment(body, articleId, user.FullName);
                if (result != null)
                {
                    message = "Comment is added.";
                }
                else
                {
                    message = "An error occured while adding the comment.";
                }
            }
            else
            {
                message = "You need to login to comment.";
            }



            return(Json(new { success = result != null, message, model = result, date = ((DateTime)result.CreationTime).ToLongDateString() }));
        }
示例#2
0
        public ArticleViewModel(Article Article)
        {
            this.Comments       = CommentCore.GetCommentByArticleId(Article.ID);
            this.LatestArticles = new List <LatestArticleRow>();
            foreach (Article article in ArticleCore.GetMostRecentArticles(5))
            {
                LatestArticles.Add(new LatestArticleRow(article.ID, article.Title, article.CreationDate));
            }

            this.LatestContributors = new List <LatestContributorsRow>();
            foreach (Contributor latestContributor in ContributorCore.GetLatestContributors(5))
            {
                LatestContributors.Add(new LatestContributorsRow(latestContributor.ID, latestContributor.Name, latestContributor.TotalContributions, latestContributor.ImageURL));
            }
            this.Affiliate = new Affiliate();
            this.Affiliate = AffiliateCore.GetAffiliatesById(Article.AffiliateID);


            Article.ViewCount = Article.ViewCount + 1;
            ID           = Article.ID;
            Title        = Article.Title;
            CreationDate = Article.CreationDate;
            ViewCount    = Article.ViewCount;//todo dbden arttır
            ArticleBody  = GetArticleBody(ArticleCore.GetArticlePiecesByArticleId(Article.ID));

            Contributor contributor = ContributorCore.GetContributorsById(Article.ContributorID);

            ContributorName  = contributor.Name;
            ContributorImage = contributor.ImageURL;
            ContributorID    = contributor.ID;
        }
示例#3
0
        public JsonResult CreateComment(CommentViewModel comment)
        {
            comment.AddedAt = DateTime.Now;
            var createdComment = CommentCore.Create(comment);

            return(Json(comment.AddedAt.ToString()));
        }
示例#4
0
        public JsonResult DeleteComment(Guid commentId)
        {
            var comment = CommentCore.Get(commentId);

            comment.Status = EntityStatus.Deleted;
            var result = CommentCore.Update(comment);

            return(Json("ok"));
        }