Skip to content

Commit dee540a

Browse files
committed
Adding Ajax
1 parent 758a7f6 commit dee540a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1047
-141
lines changed

EPAM.MyBlog.DAL.DB/DAL.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public bool Registration(Entities.User user, int role = 3)
5555
command.Parameters.Add(new SqlParameter("@Role_Id", role));
5656
con.Open();
5757
int num = command.ExecuteNonQuery();
58-
if (num == 1)
58+
if (num == 1 & AddUserInfo(user.Name))
5959
{
6060
logger.Info("DB: Добавлен новый пользователь: " + user.Name);
6161
return true;
@@ -161,7 +161,7 @@ public void SaveReason(string reason)
161161

162162
public bool AddPost(Entities.PostText post, string login)
163163
{
164-
string[] split = post.Tags.Split(' ');
164+
string[] split = post.Tags.Trim().Split(' ');
165165
for (int i = 0; i < split.Length; i++)
166166
{
167167
using (SqlConnection con = new SqlConnection(ConnectionString))
@@ -250,8 +250,6 @@ public Entities.PostText GetPostById(Guid Id)
250250
{
251251
StringBuilder s = new StringBuilder();
252252

253-
254-
255253
using (SqlConnection con = new SqlConnection(ConnectionString))
256254
{
257255
SqlCommand command = new SqlCommand("SELECT Post_Id, Post_Title, Post_Text, User_Name, Time FROM dbo.Posts WHERE Post_Id = @Id", con);
@@ -287,7 +285,7 @@ public Entities.PostText GetPostById(Guid Id)
287285
while (reader2.Read())
288286
{
289287
s.Append((string)reader2["Tag"]);
290-
s.Append(", ");
288+
s.Append(" ");
291289
}
292290
}
293291
post.Tags = s.ToString();
@@ -320,7 +318,7 @@ public bool EditPostById(Entities.PostText post)
320318
con2.Close();
321319
}
322320

323-
string[] split = post.Tags.Split(' ');
321+
string[] split = post.Tags.Trim().Split(' ');
324322
for (int i = 0; i < split.Length; i++)
325323
{
326324
using (SqlConnection con2 = new SqlConnection(ConnectionString))
@@ -615,6 +613,27 @@ public bool DeleteCommentById(Guid id)
615613
}
616614
}
617615

616+
public bool AddUserInfo(string login)
617+
{
618+
using (SqlConnection con = new SqlConnection(ConnectionString))
619+
{
620+
SqlCommand command = new SqlCommand("INSERT INTO dbo.UserAbout (Login) VALUES (@Login)", con);
621+
command.Parameters.Add(new SqlParameter("@Login", login));
622+
con.Open();
623+
int num = command.ExecuteNonQuery();
624+
if (num == 1)
625+
{
626+
return true;
627+
}
628+
else
629+
{
630+
return false;
631+
}
632+
}
633+
634+
}
635+
636+
618637
public Entities.UserInfo GetUserInfo(string name)
619638
{
620639
using (SqlConnection con = new SqlConnection(ConnectionString))
@@ -866,7 +885,7 @@ public bool AddAvatar(Entities.Avatar avatar)
866885
{
867886
using (SqlConnection con = new SqlConnection(ConnectionString))
868887
{
869-
SqlCommand command = new SqlCommand("SELECT [Post_Id], [Post_Title] FROM [Blog].dbo.Posts WHERE Post_Text LIKE @Text ORDER BY [Blog].dbo.Posts.Time DESC", con);
888+
SqlCommand command = new SqlCommand("SELECT [Post_Id], [Post_Title] FROM [Blog].dbo.Posts WHERE Post_Text LIKE @Text OR Post_Title LIKE @Text ORDER BY [Blog].dbo.Posts.Time DESC", con);
870889
command.Parameters.Add(new SqlParameter("@Text", p));
871890
con.Open();
872891
var reader = command.ExecuteReader();
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

EPAM.MyBlog.UI.Web/App_Start/BundleConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public static void RegisterBundles(BundleCollection bundles)
2929

3030
bundles.Add(new ScriptBundle("~/bundles/my").Include(
3131
"~/Scripts/include/script2.js"));
32+
33+
bundles.Add(new ScriptBundle("~/bundles/my2").Include(
34+
"~/Scripts/include/script1.js"));
3235
}
3336
}
3437
}
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+

2+
.container-fluid{
3+
width:1400px;
4+
}
5+
.container-fluid .row{
6+
margin: 0px;
7+
text-align:center;
8+
margin-bottom:10px;
9+
}
10+
11+
.navbar-static-top{
12+
margin-bottom:0px;
13+
}
14+
body{
15+
background-image: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/cropped-345656.jpg);
16+
background-attachment: fixed;
17+
}
18+
19+
html > /**/ body #sidebar {
20+
background:rgb(245,221,194);
21+
background: transparent\9;
22+
background:rgba(245,221,194,0.5);
23+
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#ccf5ddc2,endColorstr=#ccf5ddc2);
24+
zoom: 1;
25+
}
26+
#sidebar:nth-child(n) {
27+
filter: none;
28+
}
29+
30+
.main{
31+
background-color:#d5c9bf;
32+
overflow:hidden;
33+
}
34+
35+
#content, #sidebar, #loading{
36+
height: 800px;
37+
38+
}
39+
40+
#loading img{
41+
width:264px;
42+
height:34px;
43+
position:absolute;
44+
left:40%;
45+
top:50%;
46+
47+
}
48+
49+
#content, #loading {
50+
-ms-word-break: break-all;
51+
word-break: break-all;
52+
overflow-y: auto;
53+
overflow-x: hidden;
54+
-ms-background-color: #cfb8a5;
55+
background-color: #cfb8a5;
56+
}
57+
58+
.head{
59+
color:white;
60+
background-color:#cbbbb6;
61+
padding:10px;
62+
margin-bottom:10px;
63+
margin-top:10px;
64+
font-family: Sans Serif;
65+
}
66+
67+
.footer{
68+
background-color:rgb(0, 0, 0);
69+
color: white;
70+
margin-bottom:10px;
71+
margin-top:10px;
72+
}
73+
74+
.shadow {
75+
-moz-box-shadow: 0 0 30px #3d3d3d;
76+
-webkit-box-shadow: 0 0 30px #3d3d3d;
77+
box-shadow: 0 0 30px #3d3d3d;
78+
}
79+
80+
.footer .row {
81+
padding:10px;
82+
text-align:center;
83+
vertical-align:middle;
84+
}
85+
86+
a img {
87+
-moz-border-radius: 5px 5px 5px 5px;
88+
-webkit-border-radius: 5px 5px 5px 5px;
89+
border-radius: 5px 5px 5px 5px;
90+
}
91+
92+
.pull-right{
93+
text-align: right;
94+
}
95+
96+
.footer a{
97+
color:white;
98+
}
99+
100+
.validation-error{
101+
color: red;
102+
}
103+
104+
.text-box {
105+
width: 250px;
106+
-moz-border-radius: 5px;
107+
-webkit-border-radius: 5px;
108+
border-radius: 5px;
109+
padding-left: 5px;
110+
}
111+
112+
p {
113+
font-family: 'Century Gothic', futura, 'URW Gothic L', Verdana, sans-serif;
114+
font-size: 16px;
115+
}
116+
117+
.title, .username, legend{
118+
font-family: Georgia, 'Times New Roman', Times, serif;
119+
font-size: 26px;
120+
}
121+
122+
.title-top, legend, fieldset{
123+
margin-top:20px;
124+
}
125+
126+
#reg{
127+
margin-top:10px;
128+
}
129+
130+
.error-login, .title{
131+
font-size: 26px;
132+
margin-top:20px;
133+
}
134+
135+
.title{
136+
border: 0;
137+
border-bottom: 1px solid #e5e5e5;
138+
display:inline-block;
139+
margin-bottom:10px;
140+
}
141+
142+
.title p{
143+
margin-top:10px;
144+
}
145+
146+
.list > div{
147+
margin-top: 20px;
148+
}
149+
150+
.table-condensed tbody
151+
{
152+
overflow:auto;
153+
max-height: 500px;
154+
}
155+
156+
.post{
157+
margin-bottom: 40px;
158+
margin-top: 40px;
159+
}
160+
161+
.bold {
162+
font-weight: bold;
163+
}
164+
165+
.btn{
166+
margin:5px 10px;
167+
168+
}
169+
170+
#srch-term {
171+
width: 300px;
172+
margin: 20px 20px;
173+
}
174+
175+
.newpost > div{
176+
padding-top: 10px;
177+
}
178+
179+
#Title, #Tags {
180+
width:75%
181+
}
182+
183+
.editor-field textarea {
184+
width : 626px;
185+
height : 400px;
186+
}
187+
188+
.gridtitle {
189+
width:90%;
190+
}
191+
.gridbutton {
192+
width:20%;
193+
}
194+
195+
.hidden{
196+
display:none;
197+
}
198+
199+
.center_btn {
200+
width:160px;
201+
margin:10px auto;
202+
}
203+
204+
.editor-field-comment textarea {
205+
width : 450px;
206+
height : 100px;
207+
}

EPAM.MyBlog.UI.Web/Content/css/style.css

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ body{
3939
}
4040

4141
#content, #loading {
42-
background-color: rgba(229, 220, 213, 0.8);
4342
-ms-word-break: break-all;
4443
word-break: break-all;
4544
overflow-y: auto;
4645
overflow-x: hidden;
46+
-ms-background-color: rgb(229, 220, 213);
47+
background-color: rgba(229, 220, 213, 0.8);
4748
}
4849

4950
.head{
@@ -172,8 +173,8 @@ p {
172173
}
173174

174175
.editor-field textarea {
175-
width : 400px;
176-
height : 100px;
176+
width : 626px;
177+
height : 400px;
177178
}
178179

179180
.gridtitle {
@@ -185,4 +186,14 @@ p {
185186

186187
.hidden{
187188
display:none;
189+
}
190+
191+
.center_btn {
192+
width:160px;
193+
margin:10px auto;
194+
}
195+
196+
.editor-field-comment textarea {
197+
width : 450px;
198+
height : 100px;
188199
}

EPAM.MyBlog.UI.Web/Controllers/AccountController.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public class AccountController : Controller
1717

1818
private static ILog logger = LogManager.GetLogger(typeof(AccountController));
1919

20+
public ActionResult Index()
21+
{
22+
return View();
23+
}
24+
25+
2026
//
2127
// GET: /Account/
2228
[AllowAnonymous]
@@ -183,7 +189,10 @@ public ActionResult DeleteAc(ConfirmModel model)
183189
LoginModel.DeleteUser(User.Identity.Name);
184190
logger.Info("Пользователь удалил свой аккаунт с логином: " + User.Identity.Name);
185191
}
186-
return RedirectToAction("Index", "Home");
192+
else
193+
{
194+
return RedirectToAction("Index", "Home");
195+
}
187196
}
188197
if (Request.IsAjaxRequest())
189198
return PartialView("DeleteAc");
@@ -247,12 +256,16 @@ public ActionResult EditSex(UserAboutModel model)
247256
else
248257
{
249258
logger.Error("Ошибка при изменении информации о поле пользователя: " + User.Identity.Name);
259+
if (Request.IsAjaxRequest())
260+
return PartialView("EditSex", model);
250261
return View(model);
251262
}
252263
}
253264
else
254265
{
255266
logger.Debug("Невалидная модель при изменении данных о поле пользователя: " + User.Identity.Name);
267+
if (Request.IsAjaxRequest())
268+
return PartialView("EditSex", model);
256269
return View(model);
257270
}
258271
}

0 commit comments

Comments
 (0)