From ead0edec370483e5e80d42cc49c67f13e28c13b1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 8 May 2021 18:46:46 +0300 Subject: Implemented account deletion --- ExamTemplate/Web/Controllers/AccountController.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'ExamTemplate/Web/Controllers/AccountController.cs') diff --git a/ExamTemplate/Web/Controllers/AccountController.cs b/ExamTemplate/Web/Controllers/AccountController.cs index d56d3df..373dd4b 100644 --- a/ExamTemplate/Web/Controllers/AccountController.cs +++ b/ExamTemplate/Web/Controllers/AccountController.cs @@ -131,10 +131,16 @@ namespace ExamTemplate.Web.Controllers return RedirectToAction("Profile", new { username = loggedInUser.Username }); } - // [HttpPost] - // public async Task DeleteProfile(string username) - // { - // throw new System.NotImplementedException(); - // } + [HttpPost] + public async Task Delete() + { + await this._userService.LogoutAsync(); + bool result = await this._userService.DeleteUserAsync(HttpContext.User); + + if (result) + return RedirectToAction("Login"); + else + return RedirectToAction("Index", "Home"); + } } } -- cgit v1.2.3