Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UserRepository : Repository<UserMaster>, IUserRepository
- {
- public UserRepository(DbContext context)
- : base(context)
- {
- }
- public UserMaster GetById(int id)
- {
- return FindBy(x => x.Userid == id).FirstOrDefault();
- }
- }
- public class UserService : EntityService<UserMaster>, IUserService
- {
- IUnitOfWork _unitOfWork;
- IUserRepository _userRepo;
- IRolePrivilegeMapRepository _rolePrevilegeMapRepo;
- IUserRoleMapRepository _userRoleMapRepo;
- public UserService(IUnitOfWork unitOfWork, IUserRepository userRepo, IRolePrivilegeMapRepository rolePrevilegeMapRepo,IUserRoleMapRepository userRoleMapRepo)
- : base(unitOfWork, userRepo)
- {
- _unitOfWork = unitOfWork;
- _userRepo = userRepo;
- _rolePrevilegeMapRepo = rolePrevilegeMapRepo;
- _userRoleMapRepo = userRoleMapRepo;
- }
- public List<int> GetUserPrevileges(string UserName)
- {
- var rolePrevilegeMap = _rolePrevilegeMapRepo.GetAll();
- var userRoleMap = _userRoleMapRepo.GetAll();
- var userMaster = _userRepo.GetAll();
- var Privs = (from rpm in rolePrevilegeMap
- join urm in userRoleMap on rpm.RoleId equals urm.Roleid
- join um in userMaster on urm.Userid equals um.Userid
- where um.Username.Equals(UserName) && rpm.IsDeleted == false && urm.IsDeleted == false
- select rpm.PrivilegedId).Distinct();
- if (Privs.Any())
- {
- return Privs.ToList();
- }
- else
- {
- return null;
- }
- }
- }
- var rolePrevilegeMap = _rolePrevilegeMapRepo.GetAll();
- var userRoleMap = _userRoleMapRepo.GetAll();
- var userMaster = _userRepo.GetAll();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement