public AudienceCreateCommand() { _conf = (IConfiguration) new ConfigurationBuilder() .AddJsonFile("clisettings.json", optional: false, reloadOnChange: true) .Build(); _map = new MapperConfiguration(x => x.AddProfile <AutoMapperProfile_EF6>()) .CreateMapper(); var env = new ContextService(InstanceContext.DeployedOrLocal); _uow = new UnitOfWork(_conf["Databases:IdentityEntities_EF6"], env); _service = new AdminService(_conf) { Grant = new ResourceOwnerGrantV2(_conf) }; IsCommand("audience-create", "Create audience"); HasRequiredOption("i|issuer=", "Enter existing issuer", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No issuer given ***"); } _issuer = _uow.Issuers.Get(QueryExpressionFactory.GetQueryExpression <E_Issuer>() .Where(x => x.Name == arg).ToLambda()) .SingleOrDefault(); if (_issuer == null) { throw new ConsoleHelpAsException($" *** No issuer '{arg}' ***"); } }); HasRequiredOption("a|audience=", "Enter new audience", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No audience given ***"); } _audienceName = arg; }); }
public void CreateIssuers() { /* * create test issuers */ foundIssuer = _uow.Issuers.Get(QueryExpressionFactory.GetQueryExpression <E_Issuer>() .Where(x => x.Name == TestDefaultConstants.IssuerName).ToLambda()) .SingleOrDefault(); if (foundIssuer == null) { foundIssuer = _uow.Issuers.Create( _map.Map <E_Issuer>(new IssuerV1() { Name = TestDefaultConstants.IssuerName, IssuerKey = TestDefaultConstants.IssuerKey, IsEnabled = true, IsDeletable = true, })); _uow.Commit(); } }
public IssuerEditCommand() { _conf = (IConfiguration) new ConfigurationBuilder() .AddJsonFile("clisettings.json", optional: false, reloadOnChange: true) .Build(); _map = new MapperConfiguration(x => x.AddProfile <AutoMapperProfile_EF6>()) .CreateMapper(); var env = new ContextService(InstanceContext.DeployedOrLocal); _uow = new UnitOfWork(_conf["Databases:IdentityEntities_EF6"], env); _service = new AdminService(_conf) { Grant = new ResourceOwnerGrantV2(_conf) }; IsCommand("issuer-edit", "Edit issuer"); HasRequiredOption("i|issuer=", "Enter existing issuer", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No issuer given ***"); } _issuer = _uow.Issuers.Get(QueryExpressionFactory.GetQueryExpression <E_Issuer>() .Where(x => x.Name == arg).ToLambda(), new List <Expression <Func <E_Issuer, object> > >() { x => x.Audiences, x => x.Claims, }) .SingleOrDefault(); if (_issuer == null) { throw new ConsoleHelpAsException($" *** No issuer '{arg}' ***"); } }); HasOption("n|name=", "Enter name", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No name given ***"); } _issuer.Name = arg; }); HasOption("d|description=", "Enter description", arg => { if (string.IsNullOrEmpty(arg)) { throw new ConsoleHelpAsException($" *** No description given ***"); } _issuer.Description = arg; }); HasOption("E|enabled=", "Is user enabled", arg => { _isEnabled = bool.Parse(arg); }); HasOption("D|deletable=", "Is user deletable", arg => { _isDeletable = bool.Parse(arg); }); }