I have project with Windows Authentication and with a controller I have a question, by that controller below, I can get information by specifying the name of branch (by typing URL into a browser address bar for example):
"http://localhost:62249/Students/TestNew/Branch1";
And it will display to the user data where branch = Branch1.
Now the question is - how can I achieve the following?
For each branchname I want specify permission to allow open this page by specifying group from ActiveDirectory. Or it's impossible and I should create 10 more controllers and specify there permission for each one.
[HttpGet]
public ActionResult TestNew(string branchname)
{
// check stuff like permissions
var db = new MovieContext();
var model = new Model();
var students = db.Student
.Where(x => x.BranchName == branchname)
.GroupBy(x => new { x.BranchName, x.Name, x.Currency, x.NoCart, x.NoAccount })
.Select(x => new
{
BranchName = x.FirstOrDefault().BranchName,
Name = x.FirstOrDefault().Name,
A_Status = x.Max(p => p.A_Status),
Currency = x.FirstOrDefault().Currency,
NoCart = x.FirstOrDefault().NoCart,
NoAccount = x.FirstOrDefault().NoAccount
}).ToList();
foreach (var item in students)
{
model.Students.Add(new Student
{
A_Status = item.A_Status,
BranchName = item.BranchName,
Name = item.Name,
NoAccount = item.NoAccount,
NoCart = item.NoCart,
Currency = item.Currency
});
}
return View(model);