-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddarticle.aspx.cs
131 lines (121 loc) · 4.47 KB
/
addarticle.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#region XD World Recipe V 2.8
// FileName: addarticle.cs
// Author: Dexter Zafra
// Date Created: 5/29/2008
// Website: www.ex-designz.net
#endregion
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XDRecipe.UI;
using XDRecipe.BL;
using XDRecipe.BL.Providers;
using XDRecipe.Common;
using XDRecipe.Model;
using XDRecipe.Security;
using XDRecipe.Common.Utilities;
using XDRecipe.BL.Providers.User;
using XDRecipe.BL.Providers.Article;
public partial class addarticle : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
HideContentIfNotLogin.Visible = true;
lblauthorname.Text = UserIdentity.UserName.ToString();
LoadDropDownListCategory.LoadDropDownCategory("Article Category", ddlarticlecategory, "Select a Category");
}
else
{
lblyouarenotlogin.Visible = true;
lblyouarenotlogin.Text = "<div style='margin-top: 12px; margin-bottom: 7px;'><img src='images/lock.gif' align='absmiddle'> You are not authorize to add an article. Please login to add an article.</div>";
}
}
public void Add_Article(Object s, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
Utility Util = new Utility();
ArticleRepository Article = new ArticleRepository();
Article.UID = UserIdentity.UserID;
Article.Author = UserIdentity.UserName;
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.CatID == 0)
{
lbvalenght.Text = "<br>Error: You must select a category where you want your article to show.";
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 > 350)
{
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
if (Article.Add(Article) != 0)
{
JSLiteral.Text = "Error occured while processing your article submission.";
return;
}
Article = null;
Util = null;
Response.Redirect("confirmsubmitarticle.aspx?mode=Added");
}
}
}