I would like to dispaly the Name Ben only as Admin and the Name User1 as User but it gives me both of them in table see picture & the code what I have tried please :
@model ePizzaHub.WebUI.ViewlModel.AdminRoleView
@{
ViewData["Title"] = "Index";
}
Admin Dashboard
Name
Email
Admin
@foreach (var item in Model.Users)
{
@item.Name
@item.Email
@foreach (var role in Model.Roles)
{
@role.Name
}
}

Hardik DhankechaPosted Sep 11, 2021, 1:32 PM
Hi Abdalla,
You need to manage role name properly in your database. Like assigning the Admin role to Ben and the User role to User1. Now only you need to attach the role name with your AdminRoleView.Users data. It will display proper role with users in the gird section.
Also, there are multiple ways to handle a role properly. As you can manage roles with another role table in db. And assign a role id to the user. Also, you can manage parent and child role concept using it.
For example :
RoleTable :
UserTable :
There are multiple ways to perform roles, roles& rights. Above is a basic and simplest way to perform roles with users. By using the above technique, you will be able to display role in a nested view under your gird. Like all users, list under admin.
Happy Coding...!!!
Rijwan AnsariPosted Sep 10, 2021, 4:45 PM
Sachin SinghPosted Sep 10, 2021, 3:17 PM