Skip to content

Commit c562876

Browse files
committed
Deleting account
1 parent dceabe4 commit c562876

15 files changed

+48
-20
lines changed

EPAM.MyBlog.DAL.DB/DAL.cs

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ public bool CheckMail(string Email)
110110
}
111111
}
112112

113+
public bool DeleteUser(string name)
114+
{
115+
using (SqlConnection con = new SqlConnection(ConnectionString))
116+
{
117+
SqlCommand command = new SqlCommand("Delete FROM dbo.Users WHERE Login = @Name", con);
118+
command.Parameters.Add(new SqlParameter("@Name", name));
119+
con.Open();
120+
int count = command.ExecuteNonQuery();
121+
if (count > 0)
122+
{
123+
return true;
124+
}
125+
else
126+
{
127+
return false;
128+
}
129+
}
130+
}
131+
113132
#endregion
114133

115134
#region Posts
@@ -346,6 +365,26 @@ public bool AddComment(Entities.Comment comment)
346365
}
347366
}
348367

368+
public bool DeleteCommentById(Guid id)
369+
{
370+
using (SqlConnection con = new SqlConnection(ConnectionString))
371+
{
372+
string text = "НЛО прилетело и оставило эту запись";
373+
SqlCommand command = new SqlCommand("UPDATE dbo.Comments SET Text = @Text", con);
374+
command.Parameters.Add(new SqlParameter("@Text", text));
375+
con.Open();
376+
int count = command.ExecuteNonQuery();
377+
if (count > 0)
378+
{
379+
return true;
380+
}
381+
else
382+
{
383+
return false;
384+
}
385+
}
386+
}
387+
349388
#endregion
350389

351390
#region Users
@@ -373,24 +412,8 @@ public bool AddComment(Entities.Comment comment)
373412

374413

375414

376-
public bool DeleteCommentById(Guid id)
377-
{
378-
using (SqlConnection con = new SqlConnection(ConnectionString))
379-
{
380-
string text = "НЛО прилетело и оставило эту запись";
381-
SqlCommand command = new SqlCommand("UPDATE dbo.Comments SET Text = @Text", con);
382-
command.Parameters.Add(new SqlParameter("@Text", text));
383-
con.Open();
384-
int count = command.ExecuteNonQuery();
385-
if (count > 0)
386-
{
387-
return true;
388-
}
389-
else
390-
{
391-
return false;
392-
}
393-
}
394-
}
415+
416+
417+
395418
}
396419
}
512 Bytes
Binary file not shown.
Binary file not shown.
512 Bytes
Binary file not shown.
Binary file not shown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public ActionResult DeleteAc(ConfirmModel model)
157157
if (model.Confirm)
158158
{
159159
LoginModel.LogOut();
160-
160+
LoginModel.DeleteUser(User.Identity.Name);
161161
}
162162
return RedirectToAction("Index", "Home");
163163
}

EPAM.MyBlog.UI.Web/Models/LoginModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,10 @@ static string GetString(byte[] bytes)
133133
}
134134

135135

136+
137+
internal static bool DeleteUser(string name)
138+
{
139+
return (GetDAL.dal.DeleteUser(name));
140+
}
136141
}
137142
}
512 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

EPAM.MyBlog.v11.suo

34 KB
Binary file not shown.

0 commit comments

Comments
 (0)