Hello,
What will be the best way to implement the following in ASPNET.Zero?
-
Version 10 ( latest)
-
Angular
-
NET.Core
Suppose that Tenants are schools , These schools have users as teachers, students and parents, I assume these will be Roles.
The Teachers will only be able to see their assigned students data,
The Parents only their kids data and
The Students only their own data.
I am wondering if this is correct way with ASPNET. Zero or what will be the recommended way. Also if there are any examples of this will be great.
Thanks.
4 Answer(s)
-
0
Hi christianharo,
I think this is a typical data permission use case.
This is a business scenario of a specific domain. You can create three static roles (teacher, parent, student). In this scenario, the teacher and students have a one-to-many relationship, and parents and students have a one-to-many relationship.
When querying specific data, different query statements need to be constructed according to three different roles. For example, if a teacher wants to view the test scores of his own students, he needs to get the teacher's Id fromICurrentUser
, and then query the associated student ID collection. Finally, LINQ JOIN test scores are obtained for all students.var students = _studentTeacherRep.GetAll().Where(st => st.TeacherId == CurrentUser.Id); var scores = _scoreRep.GetAll() .Join(students, score => score.StudentId, student => student.StudentId, (score, student) => score) .ToList();
(Organization Unit Management may help you.)
-
0
Hi Zony,
Thansk for your answer however i was looking for something a little structured like DataFilters, as you Said Organization managment will be a good place , are there implemented filters or custom data filters I could use for the organizaiton Unit ?
-
1
Hi @christianharo,
If you want to use this approach in a limited number of pages, you can directly filter data using a LINQ where clasue. If you want to do this in the entire app, you can define a data filter as explained in the below tutorial;
https://aspnetboilerplate.com/Pages/Documents/Articles\How-To\add-custom-data-filter-ef-core
-
1
Thank you. This is what I was looking for appreciate your help.