示例#1
0
        public AddRolesOutput AddRoles(AddRolesIntput input)
        {
            var sysRole_entity = _sysRoleRepository.FirstOrDefault(o => o.Name.Equals(input.Name));

            if (sysRole_entity != null)
            {
            }

            // var auth_dto_list = new List<AuthDto>();
            // var auth_list = new List<Auth>();
            var role_id = _sysRoleRepository.InsertAndGetId(new SysRole {
                Name = input.Name
            });
            var array = input.Auth;

            foreach (var a in array)
            {
                _roleAuthRepository.InsertAndGetId(new RoleAuth {
                    AuthId = a, RoleId = role_id
                });
            }
            //var   auth_list = _authRepository.GetAllList(p => p.Id  in  array);
            var auth_list = (from p in _authRepository.GetAllList()
                             where array.Contains(p.Id)
                             select p).ToList();
            var            auth_dto_list  = Mapper.Map <List <Auth>, List <AuthDto> >(auth_list);
            AddRolesOutput addRolesOutput = new AddRolesOutput();

            addRolesOutput.Id    = role_id;
            addRolesOutput.Name  = input.Name;
            addRolesOutput.Auths = auth_dto_list.ToArray();
            return(addRolesOutput);
        }
        public AddRolesOutput  AddRoles(AddRolesIntput input)
        {
            AddRolesOutput s = _ISysRoleService.AddRoles(input);

            return(s);
        }