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();
- }
- }
any help or improvement please
i ll apriciate any help.


Farhan AhmedRank #73 · 25K reputationPosted Oct 10, 2018, 3:57 PM EDT
Ruchi SharavatRank #1,714 · 885 reputationPosted Oct 10, 2018, 9:57 PM EDT
Ruchi SharavatRank #1,714 · 885 reputationPosted Oct 11, 2018, 2:40 AM EDT
Thabo Happy66 reputationPosted Oct 11, 2018, 2:36 AM EDT
Thabo Happy66 reputationPosted Oct 11, 2018, 5:56 AM EDT