コード例 #1
0
    public void Update_Article(Object s, EventArgs e)
    {
        ArticleRepository Article = new ArticleRepository();

        Article.ID = (int)Util.Val(Request.QueryString["aid"]);
        Article.UID = int.Parse(Request.Form["Userid"]);
        Article.Title = Request.Form["Title"];
        Article.Content = Request.Form["Content"];
        Article.CatID = int.Parse(Request.Form["ddlarticlecategory"]);
        Article.Keyword = Request.Form["Keyword"];
        Article.Summary = Request.Form["Summary"];

        //Refresh cache
        Caching.PurgeCacheItems("Newest_Articles");
        Caching.PurgeCacheItems("ArticleCategory_SideMenu");

        //Notify user if error occured.
        if (Article.Update(Article) != 0)
        {
            JSLiteral.Text = Util.JSProcessingErrorAlert;
            return;
        }

        //Release allocated memory
        Article = null;

        //If success, redirect to article update confirmation page.
        Util.PageRedirect(7);

        Util = null;
    }
コード例 #2
0
    public void Update_Article(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            ArticleRepository Article = new ArticleRepository();

            Article.UID = UserIdentity.UserID;
            Article.ID = (int)Util.Val(Request.QueryString["aid"]);
            Article.Title = Util.FormatTextForInput(Request.Form["Title"]);
            Article.Summary = Util.FormatTextForInput(Request.Form["Summary"]);
            Article.Content = Request.Form["Content"];
            Article.CatID = Int32.Parse(Request.Form["ddlarticlecategory"]);
            Article.Keyword = Util.FormatTextForInput(Request.Form["Keyword"]);

            #region Form Input Validator
            if (Article.Title.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Title is blank, please enter a title.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Summary is blank, please enter a summary.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Content.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Content is blank, please enter a content.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Keyword is blank, please enter a keyword.";
                lbvalenght.Visible = true;
                return;
            }
            //if (Article.Content.Length > 8000)
            //{
            //    lbvalenght.Text = "<br>Error: Content is too long, max of 8000 characters including HTML formatting.";
            //    lbvalenght.Visible = true;
            //    return;
            //}
            if (Article.Title.Length > 65)
            {
                lbvalenght.Text = "<br>Error: Title is too long, should not exceed 65 characters.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length > 800)
            {
                lbvalenght.Text = "<br>Error: Summary is too long, max of 350 characters.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length > 80)
            {
                lbvalenght.Text = "<br>Error: Keyword is too long, max of 80 characters.";
                lbvalenght.Visible = true;
                return;
            }

            #endregion

            //Refresh cache
            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");

            if (Article.Update(Article) != 0)
            {
                JSLiteral.Text = "Error occured while processing your article submission.";
                return;
            }

            Article = null;

            Response.Redirect("confirmsubmitarticle.aspx?mode=Updated");
        }
    }