Skip to content

Commit 88eb052

Browse files
committed
Video, images
1 parent dee540a commit 88eb052

Some content is hidden

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

56 files changed

+1596
-163
lines changed

EPAM.MyBlog.DAL.DB/DAL.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public void SaveReason(string reason)
150150
SqlCommand command = new SqlCommand("INSERT INTO dbo.Reasons VALUES (@Reason)", con);
151151
command.Parameters.Add(new SqlParameter("@Reason", reason));
152152
con.Open();
153+
command.ExecuteNonQuery();
153154
}
154155
}
155156

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,8 @@ p {
196196
.editor-field-comment textarea {
197197
width : 450px;
198198
height : 100px;
199+
}
200+
201+
.comment{
202+
padding:10px;
199203
}
9.31 KB
Loading
32.8 KB
Loading

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ public ActionResult Index()
2626
//
2727
// GET: /Account/
2828
[AllowAnonymous]
29-
public ActionResult Login(string ReturnUrl)
29+
public ActionResult Login()
3030
{
31-
32-
if (string.IsNullOrWhiteSpace(ReturnUrl))
33-
{
34-
ReturnUrl = "";
35-
}
36-
ViewData.Add("ReturnUrl", ReturnUrl);
3731
if (Request.IsAjaxRequest())
3832
return PartialView("Login");
3933
return View();
@@ -42,7 +36,7 @@ public ActionResult Login(string ReturnUrl)
4236
[AllowAnonymous]
4337
[ValidateAntiForgeryToken]
4438
[HttpPost]
45-
public ActionResult Login(LoginModel model, string ReturnUrl)
39+
public ActionResult Login(LoginModel model)
4640
{
4741
var checkbox = Request.Form["remember1"];
4842
if (checkbox == "on")
@@ -58,14 +52,8 @@ public ActionResult Login(LoginModel model, string ReturnUrl)
5852
string Result;
5953
if (model.Login(out Result))
6054
{
61-
if (!string.IsNullOrWhiteSpace(ReturnUrl))
62-
{
63-
return Redirect(ReturnUrl);
64-
}
65-
else
66-
{
67-
return RedirectToAction("Index", "Home");
68-
}
55+
56+
return RedirectToAction("Index", "Home");
6957
}
7058
else
7159
{
@@ -138,6 +126,7 @@ public ActionResult LogOut(ConfirmModel model)
138126
{
139127
LoginModel.LogOut();
140128
logger.Info("Пользователь вышел из системы: " + User.Identity.Name);
129+
return RedirectToAction("Index", "Home");
141130

142131
}
143132
return RedirectToAction("Index", "Home");
@@ -148,22 +137,28 @@ public ActionResult LogOut(ConfirmModel model)
148137
}
149138

150139
[AllowAnonymous]
151-
[ChildActionOnly]
140+
152141
public ActionResult State()
153142
{
143+
if (Request.IsAjaxRequest())
144+
return PartialView("State");
154145
return PartialView();
155146
}
147+
148+
156149
[AllowAnonymous]
157-
[ChildActionOnly]
150+
//[ChildActionOnly]
158151
public ActionResult MenuState()
159152
{
153+
if (Request.IsAjaxRequest())
154+
return PartialView("MenuState");
160155
return PartialView();
161156
}
162157

163158

164159

165160
[AllowAnonymous]
166-
[ChildActionOnly]
161+
167162
public ActionResult TitleState()
168163
{
169164
return PartialView();
@@ -188,6 +183,7 @@ public ActionResult DeleteAc(ConfirmModel model)
188183
LoginModel.SaveReason(model.Reason);
189184
LoginModel.DeleteUser(User.Identity.Name);
190185
logger.Info("Пользователь удалил свой аккаунт с логином: " + User.Identity.Name);
186+
return RedirectToAction("Index", "Home");
191187
}
192188
else
193189
{
@@ -296,12 +292,16 @@ public ActionResult EditDate(UserAboutModel model)
296292
else
297293
{
298294
logger.Error("Ошибка при изменении даты рождения пользователя: " + User.Identity.Name);
295+
if (Request.IsAjaxRequest())
296+
return PartialView("EditDate");
299297
return View(model);
300298
}
301299
}
302300
else
303301
{
304302
logger.Debug("Невалидная модель при изменении даты рождения пользователе: " + User.Identity.Name);
303+
if (Request.IsAjaxRequest())
304+
return PartialView("EditDate");
305305
return View(model);
306306
}
307307
}
@@ -334,12 +334,16 @@ public ActionResult EditName(UserAboutModel model)
334334
else
335335
{
336336
logger.Error("Ошибка при изменении имени пользователя: " + User.Identity.Name);
337+
if (Request.IsAjaxRequest())
338+
return PartialView("EditName");
337339
return View(model);
338340
}
339341
}
340342
else
341343
{
342344
logger.Debug("Невалидная модель при изменении имени пользователя: " + User.Identity.Name);
345+
if (Request.IsAjaxRequest())
346+
return PartialView("EditName");
343347
return View(model);
344348
}
345349
}
@@ -373,12 +377,16 @@ public ActionResult EditAbout(UserAboutModel model)
373377
else
374378
{
375379
logger.Error("Ошибка при изменении информации о себе пользователя: " + User.Identity.Name);
380+
if (Request.IsAjaxRequest())
381+
return PartialView("EditAbout");
376382
return View(model);
377383
}
378384
}
379385
else
380386
{
381387
logger.Debug("Невалидная модель при изменении информации о себе пользователя: " + User.Identity.Name);
388+
if (Request.IsAjaxRequest())
389+
return PartialView("EditAbout");
382390
return View(model);
383391
}
384392
}

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public ActionResult UserComments(string name)
112112
public ActionResult DeletePost(Guid Id, string name)
113113
{
114114
var post = PostModel.GetPostById(Id);
115-
ViewData["Title"] = post.Title;
116115
ViewData["name"] = name;
116+
ViewData["ptitle"] = post.Title;
117117
if (Request.IsAjaxRequest())
118118
return PartialView("DeletePost");
119119
return View();
@@ -133,12 +133,16 @@ public ActionResult DeletePost(Guid id, ConfirmModel model, string name)
133133
else
134134
{
135135
logger.Error("Ошибка удаления поста " + id);
136+
if (Request.IsAjaxRequest())
137+
return PartialView("DeletePost");
136138
return View();
137139
}
138140
}
139141
else
140142
{
141143
logger.Debug("Невалидная модель удаления поста " + id);
144+
if (Request.IsAjaxRequest())
145+
return PartialView("DeletePost");
142146
return View();
143147
}
144148
}
@@ -168,15 +172,22 @@ public ActionResult DeleteComment(Guid id, ConfirmModel model, string name)
168172
if (CommentModel.Delete(id))
169173
{
170174
logger.Info("Удаление комментария " + id);
171-
return RedirectToAction("UserComments", "Admin", new {name = name});
175+
return RedirectToAction("UserComments", "Admin", new { name = name });
172176
}
173177
else
174178
{
175179
logger.Error("Ошибка удаления комментария " + id);
180+
if (Request.IsAjaxRequest())
181+
return PartialView("DeleteComment");
176182
return View();
177183
}
178184
}
179-
return View();
185+
else
186+
{
187+
if (Request.IsAjaxRequest())
188+
return PartialView("DeleteComment");
189+
return View();
190+
}
180191
}
181192

182193

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace EPAM.MyBlog.UI.Web.Controllers
1010
{
11+
1112
public class CommentController : Controller
1213
{
1314
private static ILog logger = LogManager.GetLogger(typeof(CommentController));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace EPAM.MyBlog.UI.Web.Controllers
1010
{
11+
[Authorize(Roles = "User")]
1112
public class FilesController : Controller
1213
{
1314

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,32 @@ public ActionResult Help()
2525
return View();
2626
}
2727

28+
public ActionResult HttpError()
29+
{
30+
if (Request.IsAjaxRequest())
31+
return PartialView("HttpError");
32+
return View();
33+
}
34+
35+
public ActionResult HttpError404()
36+
{
37+
if (Request.IsAjaxRequest())
38+
return PartialView("HttpError404");
39+
return View();
40+
}
41+
42+
public ActionResult HttpError500()
43+
{
44+
if (Request.IsAjaxRequest())
45+
return PartialView("HttpError500");
46+
return View();
47+
}
48+
49+
public ActionResult HttpError403()
50+
{
51+
if (Request.IsAjaxRequest())
52+
return PartialView("HttpError403");
53+
return View();
54+
}
2855
}
2956
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ public ActionResult NewPost()
3737
}
3838

3939
[HttpPost]
40+
[ValidateInput(true)]
4041
public ActionResult NewPost(PostModel model)
4142
{
4243
model.Id = Guid.NewGuid();
4344
model.Time = DateTime.Now;
4445
if (ModelState.IsValid)
4546
{
47+
if (model.Text.ToLower().IndexOf("<script>") != -1 || model.Text.ToLower().IndexOf("style") != -1)
48+
{
49+
if (Request.IsAjaxRequest())
50+
return PartialView("NewPost");
51+
}
4652
//string Result;
4753
if (model.AddPost(User.Identity.Name.ToString()))
4854
{
@@ -51,9 +57,13 @@ public ActionResult NewPost(PostModel model)
5157
}
5258
else
5359
{
60+
if (Request.IsAjaxRequest())
61+
return PartialView("NewPost");
5462
return View();
5563
}
5664
}
65+
if (Request.IsAjaxRequest())
66+
return PartialView("NewPost");
5767
return View();
5868
}
5969

@@ -65,6 +75,7 @@ public ActionResult MyPosts()
6575
return View(PresentPostModel.GetAllPostsTitle(User.Identity.Name));
6676
}
6777

78+
[AllowAnonymous]
6879
public ActionResult Posts(Guid Id)
6980
{
7081
ViewData["Check"] = PostModel.CheckFavorite(User.Identity.Name, Id).ToString();
@@ -103,6 +114,11 @@ public ActionResult Edit(PostModel post)
103114
post.Time = DateTime.Now;
104115
if (ModelState.IsValid)
105116
{
117+
if (post.Text.ToLower().IndexOf("<script>") != -1 || post.Text.ToLower().IndexOf("style") != -1)
118+
{
119+
if (Request.IsAjaxRequest())
120+
return PartialView("Edit");
121+
}
106122
if (post.EditPost())
107123
{
108124
logger.Info("Изменен пост id: " + post.Id + "у пользователя: " + User.Identity.Name);
@@ -139,6 +155,7 @@ public ActionResult Delete(Guid id, ConfirmModel model)
139155
{
140156
if (model.Confirm)
141157
{
158+
142159
if (PostModel.Delete(id))
143160
{
144161
logger.Info("Удален пост id: " + id + "у пользователя: " + User.Identity.Name);
@@ -186,6 +203,8 @@ public ActionResult DeleteFavorite(Guid id, ConfirmModel model)
186203
else
187204
{
188205
logger.Error("Ошибка при удалении поста id: " + id + "из Избранного у пользователя: " + User.Identity.Name);
206+
if (Request.IsAjaxRequest())
207+
return PartialView("DeleteFavorite", new { Id = id });
189208
return View();
190209
}
191210
}
@@ -194,9 +213,12 @@ public ActionResult DeleteFavorite(Guid id, ConfirmModel model)
194213
return RedirectToAction("Favorite", "Post");
195214
}
196215
}
216+
if (Request.IsAjaxRequest())
217+
return PartialView("DeleteFavorite");
197218
return View();
198219
}
199220

221+
[AllowAnonymous]
200222
public ActionResult Comments(Guid id)
201223
{
202224
return View();

0 commit comments

Comments
 (0)