Hello am trying to count registered users from my database
so i came up with something like this:
- public class HomeController : Controller
- {
- private ApplicationDbContext db = new ApplicationDbContext();
-
- public ActionResult Index()
- {
- if(User.IsInRole("Tutor"))
- {
- ViewData["TutorCount"] = db.Users.Count();
- }
- else
- {
- ViewData["StudentCount"] = db.Users.Count();
- }
-
- return View();
- }
- }
but doesn't seem to be working
any help or improvement please
i ll apriciate any help.