I have a table of clubs, when a new one is created a new role is created Club(the id of the club)Admin.
I want to be able to reference this role in the authorisation attribute of the method.
Heres what Ive tried on the controller method:
[Authorize(Roles = "Club" + clubId + "Admin")]
public ActionResult ClubDetails(int clubId)
{
var viewModel = db.Clubs
.Where(t => t.ClubId == clubId)
.Select(t => new ClubDetailsViewModel
{
ClubId = t.ClubId,
Name = t.Name,
ShortName = t.ShortName,
Founded = t.Founded,
ContactName = t.FirstName + " " + t.LastName,
Address1 = t.Address1,
Address2 = t.Address2,
City = t.City,
County = t.County,
Postcode = t.Postcode,
Telephone = t.Telephone,
Email = t.Email,
Website = t.Website,
Bio = t.Bio,
ClubTypeId = t.ClubTypeId,
MembershipStatusId = t.MembershipStatusId,
ChequesPayable = t.ChequesPayable,
BACSAcc = t.BACSAcc,
BACSSort = t.BACSSort,
PaypalAdd = t.PaypalAddress,
})
.FirstOrDefault();
return View(viewModel);
}
But that gives an error on clubId in the authorise attribute. The name clubId does not exist in the current context
Is there a way I can reference the parameter that is passed to the method in the authorise attribute?