Hi there
is any way I can do a multi-user app and every user sees only its postings. only administrator can see all the posts
thanks I advance
Hi @scryde,
This is covered in our Complete Application Tutorial.
public partial class OpportunitiesController
{
partial void OnOpportunityCreated(Opportunity item)
{
var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
// Set the UserId property of the opportunity to the current user's id
item.UserId = userId;
}
partial void OnOpportunitiesRead(ref IQueryable<Opportunity> items)
{
var role = User.FindFirst(ClaimTypes.Role).Value;
if (role != "Sales Manager")
{
var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
// Filter the opportunities by the current user's id
items = items.Where(item => item.UserId == userId);
}
}
}
Hi,
How can I add another role in this line: if (role != "Sales Manager")
I have tried:
if (role != "Sales Manager" || "Administrator")
if (role != "Sales Manager", "Administrator")
if (role != ["Sales Manager","Administrator"])
if (role != (["Sales Manager","Administrator"]))
if (role != ("[Sales Manager,Administrator]"))
if ((role != "Sales Manager") || (role != "Administrator"))
if (role != "Sales Manager, Administrator")
I would appreciate any help on this.
Thanks
Never mind.. sometimes the obvious is hardest to see.
I just added the User to both Roles Administrator and Sales Manager
Forgot about the multi roles.
Cheers