Exemplo n.º 1
0
        public void AddUserToRole()
        {
            Database userDatabase = ServiceTools.GetUserDatabase();
            string   email        = Prompt("Please enter the user's email address");
            User     user         = User.FirstOneWhere(u => u.Email == email, userDatabase);

            if (user == null)
            {
                OutLine("Unable to find a user with the specified address", ConsoleColor.Yellow);
                return;
            }
            string role    = Prompt("Please enter the role to add the user to");
            Role   daoRole = Role.FirstOneWhere(r => r.Name == role, userDatabase);

            if (daoRole == null)
            {
                daoRole = new Role(userDatabase)
                {
                    Name = role
                };
                daoRole.Save(userDatabase);
            }
            Role existing = user.Roles.FirstOrDefault(r => r.Name.Equals(daoRole.Name));

            if (existing == null)
            {
                user.Roles.Add(daoRole);
                user.Save(userDatabase);
                Message.PrintLine("User ({0}) added to role ({1})", user.UserName, daoRole.Name);
            }
            else
            {
                OutLine("User already in specified role");
            }
        }
Exemplo n.º 2
0
        public void SendMessage()
        {
            string email   = GetArgument("sendEmail", "Please enter the email address to send to");
            string subject = GetArgument("subject", "Please enter the message subject");
            string message = GetArgument("message", "Please enter the message body");
            string from    = GetArgument("from", "Please enter the from display name");

            NotificationService svc = ServiceTools.GetService <NotificationService>();

            svc.NotifyRecipientEmail(email, message, subject, null, from);
        }
        private void Login()
        {
            UserInfo      userInfo      = ServiceTools.GetUserInfo();
            LoginResponse loginResponse = _client.Login(userInfo.Email, userInfo.Password.Sha1());

            if (!loginResponse.Success)
            {
                Message.PrintLine("Log in failed: {0}", ConsoleColor.Yellow, loginResponse.Message);
                return;
            }
        }
        public void SignUp()
        {
            UserInfo       info     = ServiceTools.GetUserInfo();
            SignUpResponse response = _client.SignUp(info.Email, info.Password);

            if (!response.Success)
            {
                OutLine(response.Message, ConsoleColor.Magenta);
            }
            else
            {
                Message.PrintLine("{0} signed up successfully", info.Email);
            }
        }
 static RemoteRegistrationActions()
 {
     _client = new CoreClient(ServiceTools.GetLogger());
 }