Skip to content

Commit

Permalink
[Added] Verify and Unverify User funtionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nobir committed Jul 20, 2022
1 parent 6a5f4c2 commit 4e109b1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,44 @@ public ActionResult Index()
return View();
}

public ActionResult VerifyUser(int id)
{
var user = this.db.Users.Where(u => u.Id == id).SingleOrDefault();

if (user == null)
{
TempData["error_message"] = "User not found";
return RedirectToAction("ViewUnverifiedUsers", "Admin");
}

user.Verified = 1;

this.db.SaveChanges();

TempData["success_message"] = "Successfully Verified the user";

return RedirectToAction("ViewUnverifiedUsers", "Admin");
}

public ActionResult UnverifyUser(int id)
{
var user = this.db.Users.Where(u => u.Id == id).SingleOrDefault();

if (user == null)
{
TempData["error_message"] = "User not found";
return RedirectToAction("ViewVerifiedUsers", "Admin");
}

user.Verified = 0;

this.db.SaveChanges();

TempData["success_message"] = "Successfully Unverified the user";

return RedirectToAction("ViewVerifiedUsers", "Admin");
}

[HttpGet]
public ActionResult ViewUnverifiedUsers(int? id)
{
Expand Down

0 comments on commit 4e109b1

Please sign in to comment.