From 4e109b132afec40255d79a7d7b079169c68eced5 Mon Sep 17 00:00:00 2001 From: Nobir Date: Wed, 20 Jul 2022 06:19:35 +0600 Subject: [PATCH] [Added] Verify and Unverify User funtionality --- Controllers/AdminController.cs | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Controllers/AdminController.cs b/Controllers/AdminController.cs index 41fdb6f..a68c5dd 100644 --- a/Controllers/AdminController.cs +++ b/Controllers/AdminController.cs @@ -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) {