Example #1
0
        public LoginShowCommand()
        {
            _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("login-show", "Show login");

            HasRequiredOption("l|login="******"Enter existing login", arg =>
            {
                if (string.IsNullOrEmpty(arg))
                {
                    throw new ConsoleHelpAsException($"  *** No login given ***");
                }

                _login = _uow.Logins.Get(QueryExpressionFactory.GetQueryExpression <E_Login>()
                                         .Where(x => x.Name == arg).ToLambda(),
                                         new List <Expression <Func <E_Login, object> > >()
                {
                    x => x.UserLogins,
                })
                         .SingleOrDefault();

                if (_login == null)
                {
                    throw new ConsoleHelpAsException($"  *** No login '{arg}' ***");
                }
            });
        }
Example #2
0
        public void CreateLogins()
        {
            /*
             * create test logins
             */

            foundLogin = _uow.Logins.Get(QueryExpressionFactory.GetQueryExpression <E_Login>()
                                         .Where(x => x.Name == TestDefaultConstants.LoginName).ToLambda())
                         .SingleOrDefault();

            if (foundLogin == null)
            {
                foundLogin = _uow.Logins.Create(
                    _map.Map <E_Login>(new LoginV1()
                {
                    Name        = TestDefaultConstants.LoginName,
                    LoginKey    = AlphaNumeric.CreateString(16),
                    IsDeletable = true,
                }));

                _uow.Commit();
            }
        }
Example #3
0
        public UserCreateCommand()
        {
            _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("user-create", "Create user");

            HasRequiredOption("l|login="******"Enter existing login", arg =>
            {
                if (string.IsNullOrEmpty(arg))
                {
                    throw new ConsoleHelpAsException($"  *** No login given ***");
                }

                _login = _uow.Logins.Get(QueryExpressionFactory.GetQueryExpression <E_Login>()
                                         .Where(x => x.Name == arg).ToLambda())
                         .SingleOrDefault();

                if (_login == null)
                {
                    throw new ConsoleHelpAsException($"  *** No login '{arg}' ***");
                }
            });

            HasRequiredOption("u|user="******"Enter new user", arg =>
            {
                if (string.IsNullOrEmpty(arg))
                {
                    throw new ConsoleHelpAsException($"  *** No user given ***");
                }

                _userName = arg;
            });

            HasRequiredOption("h|human=", "Is new user human", arg =>
            {
                _human = bool.Parse(arg);
            });

            HasRequiredOption("g|given=", "Given (first) name", arg =>
            {
                if (string.IsNullOrEmpty(arg))
                {
                    throw new ConsoleHelpAsException($"  *** No given (first) name given ***");
                }

                _firstName = arg;
            });

            HasRequiredOption("s|surname=", "Surname (last) name", arg =>
            {
                if (string.IsNullOrEmpty(arg))
                {
                    throw new ConsoleHelpAsException($"  *** No surname (last) name given ***");
                }

                _lastName = arg;
            });
        }