Beispiel #1
0
        public Framework.Common.Service.Message.ResponseDto AssignRoles(List <Common.DTO.RoleDto> roles, int groupId)
        {
            ResponseDto response = new ResponseDto();
            var         group    = GetSingle(it => it.SecurityGroupId == groupId);

            if (group != null)
            {
                RoleToGroupTDataAccess roleToGroupDa = new RoleToGroupTDataAccess();
                List <RoleToGroupDto>  assignList    = new List <RoleToGroupDto>();
                foreach (var role in roles)
                {
                    RoleToGroupDto utg = new RoleToGroupDto()
                    {
                        RoleId  = role.RoleId,
                        GroupId = groupId
                    };
                    var relation = roleToGroupDa.GetSingle(it => it.RoleId == role.RoleId && it.GroupId == groupId);
                    if (relation == null)
                    {
                        assignList.Add(utg);
                    }
                }
                roleToGroupDa.Insert(assignList);
            }
            else
            {
                response.Response.AddBusinessException("چنین گروهی موجود نیست!", BusinessExceptionEnum.Operational);
            }
            return(response);
        }
Beispiel #2
0
        public SecurityGroupDtoContainer RoleGroups(RoleDto role)
        {
            SecurityGroupDtoContainer container     = new SecurityGroupDtoContainer();
            RoleToGroupTDataAccess    roleToGroupDa = new RoleToGroupTDataAccess();
            var groupList = roleToGroupDa.GetRoleGroups(role);

            container.SecurityGroupDtoList.AddRange(groupList);
            return(container);
        }