예제 #1
0
    protected void btnCommit_ServerClick(object sender, EventArgs e)
    {
        int     id      = Convert.ToInt32(Request.QueryString["aid"]);
        Article article = ArticleManager.GetArticleById(id);

        string commentContent = Server.HtmlEncode(this.txtComment.Text.ToString());

        if (commentContent.Length > 250)
        {
            commentContent = commentContent.Substring(0, 250);
        }
        Comment comment = new  Comment();

        comment.Article    = article;
        comment.AuthorName = this.txtCommentName.Text.ToString();
        comment.Contents   = commentContent;
        comment.PubDate    = DateTime.Now;
        if (CommentManager.AddComment(comment) != null)
        {
            Response.Redirect("article.aspx?aid=" + id);
            Response.Write("alert(\"恭喜您,评论发表成功!\")");
        }
        else
        {
            this.lblErrorComment.Text = "很抱歉,你的评论发表失败,请重新尝试!";
        }
    }
예제 #2
0
        public void UpdateArticle(string articleId, ArticleInfo_Add article)
        {
            using (var biz = new GameBiz.Business.GameBizBusinessManagement())
            {
                biz.BeginTran();
                using (var manager = new ArticleManager())
                {
                    var entity = manager.GetArticleById(articleId);
                    if (entity == null)
                    {
                        throw new ArgumentException("指定编号的文章不存在");
                    }

                    var keyWordsList = manager.QuerKeywordOfArticle();
                    var content      = DeepReplaceContent(article.Description, keyWordsList);

                    var tagList = new List <string>();
                    tagList.Add("script");
                    content = UsefullHelper.ReplaceHtmlTag(content, tagList);

                    entity.Title                 = article.Title;
                    entity.KeyWords              = article.KeyWords;
                    entity.DescContent           = article.DescContent;
                    entity.GameCode              = article.GameCode;
                    entity.Description           = content;
                    entity.IsRedTitle            = article.IsRedTitle;
                    entity.Category              = article.Category;
                    entity.UpdateTime            = DateTime.Now;
                    entity.UpdateUserKey         = article.CreateUserKey;
                    entity.UpdateUserDisplayName = article.CreateUserDisplayName;
                    manager.UpdateArticle(entity);
                }
                biz.CommitTran();
            }
        }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                int     id      = Convert.ToInt32(Request.QueryString["aid"]);
                Article article = ArticleManager.GetArticleById(id);
                article.Clicks += 1;

                if (article == null || article.Equals(null))
                {
                    this.Page.Title      = "此文章不存在,或被管理员删除,请见谅";
                    this.lblcontent.Text = "此文章不存在,或被管理员删除,请见谅!";
                }
                else
                {
                    this.lbltitle.Text    = article.Title;
                    this.Page.Title       = article.Title;
                    this.lblposttime.Text = article.PubDate.ToString();
                    this.lblcontent.Text  = article.Contents;
                    article.Clicks       += 1;
                    ArticleManager.ModifyArticle(article);
                }
            }
            catch
            {
                Response.Redirect("refresh.aspx?msg=" + "此文章不存在,或被管理员删除,请见谅!");
            }
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            string articleId = Request.QueryString["articleId"];

            if (string.IsNullOrEmpty(articleId))
            {
                // New article.
                _create         = true;
                saveButton.Text = "Create";
            }
            else
            {
                // Edit an existing article.
                if (int.TryParse(articleId, out int id))
                {
                    ArticleInfo article = ArticleManager.GetArticleById(id, false);
                    title.Text           = article.Title;
                    content.Text         = article.Content;
                    articleIdField.Value = article.Id.ToString();
                }
            }
        }
예제 #5
0
        public async Task <ActionResult> ArticleDetails(Guid?id)
        {
            var articleManager = new ArticleManager();

            if (id == null || !await articleManager.ExistsArticle(id.Value))
            {
                return(RedirectToAction(nameof(ArticleList)));
            }
            var comments = await articleManager.GetCommentByArticleId(id.Value);

            ViewBag.Comments = comments.AsQueryable();
            return(View(await articleManager.GetArticleById(id.Value)));
        }
예제 #6
0
        public async Task <ActionResult> EditArticle(Guid id)
        {
            var articleManager = new ArticleManager();
            var data           = await articleManager.GetArticleById(id);

            var userId = Guid.Parse(Session["userId"].ToString());

            ViewBag.CategoryIds = await new ArticleManager().GetAllCategories(userId);
            return(View(new EditArticleViewModel()
            {
                ArticleId = data.ArticleId,
                Title = data.Title,
                Content = data.Content,
                CategoryIds = data.CategoryIds
            }));
        }
예제 #7
0
 public void DeleteArticle(string articleId)
 {
     using (var biz = new GameBiz.Business.GameBizBusinessManagement())
     {
         biz.BeginTran();
         using (var manager = new ArticleManager())
         {
             var entity = manager.GetArticleById(articleId);
             if (entity == null)
             {
                 throw new ArgumentException("指定要删除的文章不存在");
             }
             manager.DeleteArticle(entity);
         }
         biz.CommitTran();
     }
 }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //显示文章
            Article art  = new Article();
            string  aids = Request.QueryString["aid"].ToString();
            int     aid  = Convert.ToInt32(aids);//文章id
            art          = ArticleManager.GetArticleById(aid);
            Title.Text   = art.NTitle;
            Author.Text  = "作者: " + art.Author.Name + " 发表时间: " + art.NDate;
            Content.Text = art.NContent;

            //显示评论
            cm = new List <comments>();
            cm = CommentsManager.GetCommentByAid(aid);
        }
    }
예제 #9
0
 public ArticleInfo_Query QueryArticleInfoById(string articleId, bool isAddReadCount)
 {
     using (var manager = new ArticleManager())
     {
         var entity = manager.GetArticleById(articleId);
         if (entity == null)
         {
             throw new ArgumentException("指定编号的文章不存在");
         }
         if (isAddReadCount)
         {
             entity.ReadCount++;
             manager.UpdateArticle(entity);
         }
         var info = new ArticleInfo_Query();
         ObjectConvert.ConverEntityToInfo <Article, ArticleInfo_Query>(entity, ref info);
         return(info);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Make sure response is clear and set to return JSON.
            Response.Clear();
            Response.ContentType = "application/json; charset=utf-8";

            // Initialize the article manager.
            ArticleManager.Initialize();

            ArticleInfo articleInfo;

            // If no query string is provided, get the latest article.
            // Otherwise get the article by id.
            string articleIdStr = Request.QueryString["lastArticleId"];

            if (string.IsNullOrEmpty(articleIdStr))
            {
                articleInfo = ArticleManager.GetLatestArticle();
            }
            else
            {
                if (int.TryParse(articleIdStr, out int articleId))
                {
                    articleInfo = ArticleManager.GetArticleById(articleId, true);
                }
                else
                {
                    throw new Exception("Unable to parse article id.");
                }
            }

            // Now that an article has been obtained, serialize it to JSON.
            string output = JsonConvert.SerializeObject(articleInfo);

            Response.Write(output);
            Response.End();
        }
예제 #11
0
        //YAZIYI GETIR
        public IEnumerable <Writing> Get(int id)
        {
            IEnumerable <Writing> yazilar = ArticleManager.GetArticleById(id);

            return(yazilar);
        }
예제 #12
0
        public IEnumerable <Writing> Get(int id)
        {
            IEnumerable <Writing> gelenYazi = ArticleManager.GetArticleById(id);

            return(gelenYazi);
        }
예제 #13
0
 private Task <IEnumerable <Article> > GetAsyncArticle(int id)
 {
     return(Task.FromResult(am.GetArticleById(id)));
 }