I would validate if the currenlty active user has permission to acces the company. Below I have two samples of GET and PUT request, to fetch company details and to updated company details. Is it possible to write a Data Annotation so I can point, or send a property to it so I'm able to validate if the user can access it?
Sample:
[ValidateCompanyPermission("companyId")]
[HttpGet]
public async Task<IActionResult> GetCompany(long companyId)
{
}
public class CompanyRequest
{
public long UpdatedById { get; set; }
public string NewCompanyName
}
[ValidateCompanyPermission("UserRequest.UpdatedById")]
[HttpPut]
public async Task<IActionResult> GetCompanz(CompanyRequest companyRequest)
{
}