Пример #1
0
        public async Task <SaveResponse> SaveSuperUser()
        {
            // save role to get ID

            int RID = await _rRepo.CreateSuperAsync();

            // get all prvileges and assign to role

            var privileges = await _pRepo.getAllAsync();

            var rolePrivileges = new List <RolePrivilege>();

            if (privileges != null)
            {
                foreach (var privilege in privileges)
                {
                    var rolePriv = new RolePrivilege
                    {
                        PrivilegeID = privilege.ID,
                        RoleID      = RID
                    };

                    rolePrivileges.Add(rolePriv);
                }

                // Assign all privileges to the role

                await _rpRepo.insertListAsync(rolePrivileges);
            }

            return(new SaveResponse {
                ID = RID, Result = "SuperUser Role Created", status = true
            });
        }
Пример #2
0
        public async Task <bool> AssignMultiplePrivileges(Role data)
        {
            var status = false;
            List <RolePrivilege> rolePrivileges = new List <RolePrivilege>();

            foreach (var pid in data.PrivilegeIDs)
            {
                var rp = new RolePrivilege
                {
                    RoleID      = data.ID,
                    PrivilegeID = pid
                };
                rolePrivileges.Add(rp);
            }
            status = await _rpRepo.insertListAsync(rolePrivileges);


            return(status);
        }