Beispiel #1
0
        public SendingMailResult SendCommentReplyNotification(CommentReplyEmailNotificationData data, CommentReplyType replyType)
        {
            var urlHelper = new UrlHelper(_httpContext.Request.RequestContext);

            var link = string.Empty;

            switch (replyType)
            {
            case CommentReplyType.ReplyToArticleComment:
                link = urlHelper.Action(MVC.Article.ActionNames.Index, MVC.Article.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;

            case CommentReplyType.ReplyToPageComment:
                link = urlHelper.Action(MVC.Page.ActionNames.Index, MVC.Page.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;

            case CommentReplyType.ReplyToPostComment:
                link = urlHelper.Action(MVC.Post.ActionNames.Index, MVC.Post.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;
            }

            link += "#comment-" + data.CommentId;

            var model = new CommentReplyNotificationModel
            {
                FromUserName = data.FromUserName,
                ToUserName   = data.ToUserName,
                PostId       = data.PostId,
                PostTitle    = data.PostTitle,
                CommentText  = data.CommentText,
                CommentLink  = link
            };

            var htmlText = _viewConvertor.RenderRazorViewToString(MVC.EmailTemplates.Views._CommentReplyNotification, model);


            var result = Send(new MailDocument
            {
                Body    = htmlText,
                Subject =
                    string.Format("شما پاسخی از طرف {0} در مطلب {1} دریافت کرده اید.", data.FromUserName, data.PostTitle),
                ToEmail = data.ToEmail
            });


            return(result);
        }
Beispiel #2
0
        public SendingMailResult SendCommentReplyNotification(CommentReplyEmailNotificationData data, CommentReplyType replyType)
        {
            var urlHelper = new UrlHelper(_httpContext.Request.RequestContext);

            var link = string.Empty;

            switch (replyType)
            {
                case CommentReplyType.ReplyToArticleComment:
                    link = urlHelper.Action(MVC.Article.ActionNames.Index, MVC.Article.Name, new
                    {
                        title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                        id = data.PostId
                    }, _httpContext.Request.Url.Scheme);
                    break;
                case CommentReplyType.ReplyToPageComment:
                    link = urlHelper.Action(MVC.Page.ActionNames.Index, MVC.Page.Name, new
                    {
                        title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                        id = data.PostId
                    }, _httpContext.Request.Url.Scheme);
                    break;
                case CommentReplyType.ReplyToPostComment:
                    link = urlHelper.Action(MVC.Post.ActionNames.Index, MVC.Post.Name, new
                    {
                        title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                        id = data.PostId
                    }, _httpContext.Request.Url.Scheme);
                    break;
            }

            link += "#comment-" + data.CommentId;

            var model = new CommentReplyNotificationModel
            {
                FromUserName = data.FromUserName,
                ToUserName = data.ToUserName,
                PostId = data.PostId,
                PostTitle = data.PostTitle,
                CommentText = data.CommentText,
                CommentLink = link
            };

            var htmlText = _viewConvertor.RenderRazorViewToString(MVC.EmailTemplates.Views._CommentReplyNotification, model);


            var result = Send(new MailDocument
             {
                 Body = htmlText,
                 Subject =
                     string.Format("شما پاسخی از طرف {0} در مطلب {1} دریافت کرده اید.", data.FromUserName, data.PostTitle),
                 ToEmail = data.ToEmail
             });


            return result;
        }