Ejemplo n.º 1
0
        public string Dispatch(string input)
        {
            string result = "";

            var commandArgs = Regex.Split(input.Trim(), @"\s");

            var command = commandArgs.Length > 0 ? commandArgs[0] : string.Empty;

            var args = commandArgs.Skip(1).ToArray();

            switch (command)
            {
            case "Login":
                result = LoginCommand.Execute(args);
                break;

            case "Logout":
                result = LogoutCommand.Execute(args);
                break;

            case "RegisterUser":
                result = RegisterUserCommand.Execute(args);
                break;

            case "DeleteUser":
                result = DeleteUserCommand.Execute(args);
                break;

            case "CreateEvent":
                result = CreateEventCommand.Execute(args);
                break;

            case "CreateTeam":
                result = CreateTeamCommand.Execute(args);
                break;

            case "InviteToTeam":
                result = InviteToTeamCommand.Execute(args);
                break;

            case "AcceptInvite":
                result = AcceptInviteCommand.Execute(args);
                break;

            case "DeclineInvite":
                result = DeclineInviteCommand.Execute(args);
                break;

            case "KickMember":
                result = KickMemberCommand.Execute(args);
                break;

            case "Exit":
                result = ExitCommand.Execute(args);
                break;

            case "Disband":
                result = DisbandCommand.Execute(args);
                break;

            case "AddTeamTo":
                result = AddTeamToCommand.Execute(args);
                break;

            case "ShowTeam":
                result = ShowTeamCommand.Execute(args);
                break;

            case "ShowEvent":
                result = ShowEventCommand.Execute(args);
                break;

            default:
                throw new NotSupportedException($"Command {command} not supported!");
            }

            return(result);
        }
Ejemplo n.º 2
0
        public string Dispatch(string input)
        {
            string[] args        = input.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            string   commandName = args.Length > 0 ? args[0] : string.Empty;

            string[] commandArgs = args.Skip(1).ToArray();

            switch (commandName)
            {
            case "ShowTeam":
                ShowTeamCommand showTeamCommand = new ShowTeamCommand();
                return(showTeamCommand.Execute(commandArgs));

            case "ShowEvent":
                ShowEventCommand showEventCommand = new ShowEventCommand();
                return(showEventCommand.Execute(commandArgs));

            case "AddTeamTo":
                AddTeamToCommand addTeamToCommand = new AddTeamToCommand(this._authManager);
                return(addTeamToCommand.Execute(commandArgs));

            case "Disband":
                DisbandCommand disbandCommand = new DisbandCommand(this._authManager);
                return(disbandCommand.Execute(commandArgs));

            case "KickMember":
                KickMemberCommand kickMemberCommand = new KickMemberCommand(this._authManager);
                return(kickMemberCommand.Execute(commandArgs));

            case "AcceptInvite":
                AcceptInviteCommand acceptInviteCommand = new AcceptInviteCommand(this._authManager);
                return(acceptInviteCommand.Execute(commandArgs));

            case "DeclineInvite":
                DeclineInviteCommand declineInviteCommand = new DeclineInviteCommand(this._authManager);
                return(declineInviteCommand.Execute(commandArgs));

            case "InviteToTeam":
                InviteToTeamCommand inviteToTeamCommand = new InviteToTeamCommand(this._authManager);
                return(inviteToTeamCommand.Execute(commandArgs));

            case "CreateTeam":
                CreateTeamCommand createTeamCommand = new CreateTeamCommand(this._authManager);
                return(createTeamCommand.Execute(commandArgs));

            case "CreateEvent":
                CreateEventCommand createEventCommand = new CreateEventCommand(this._authManager);
                return(createEventCommand.Execute(commandArgs));

            case "Exit":
                ExitCommand exitCommand = new ExitCommand();
                return(exitCommand.Execute(new string[0]));

            case "RegisterUser":
                RegisterUserCommand registerUserCommand = new RegisterUserCommand(_authManager);
                return(registerUserCommand.Execute(commandArgs));

            case "Login":
                LoginCommand loginCommand = new LoginCommand(this._authManager);
                return(loginCommand.Execute(commandArgs));

            case "Logout":
                LogoutCommand logoutCommand = new LogoutCommand(this._authManager);
                return(logoutCommand.Execute(commandArgs));

            case "DeleteUser":
                DeleteUserCommand deleteUserCommand = new DeleteUserCommand(this._authManager);
                return(deleteUserCommand.Execute(commandArgs));

            default:
                throw new NotSupportedException($"Command {commandName} not supported!");
            }
        }
        public string Dispatch(string input)
        {
            string result = string.Empty;;

            string[] inputArgs = input
                                 .Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            string commandName = inputArgs.Length > 0 ? inputArgs[0].ToLower() : string.Empty;

            inputArgs = inputArgs.Skip(1).ToArray();

            switch (commandName)
            {
            case "registeruser":
                result = RegisterUserCommand.Execute(inputArgs);
                break;

            case "deleteuser":
                result = DeleteUserCommand.Execute(inputArgs);
                break;

            case "login":
                result = LoginCommand.Execute(inputArgs);
                break;

            case "logout":
                result = LogoutCommand.Execute(inputArgs);
                break;

            case "createevent":
                result = CreateEventInternalCommand.Execute(inputArgs);
                break;

            case "createteam":
                result = CreateTeamCommand.Execute(inputArgs);
                break;

            case "showevent":
                result = ShowEventCommand.Execute(inputArgs);
                break;

            case "showteam":
                result = ShowTeamCommand.Execute(inputArgs);
                break;

            case "kickmember":
                result = KickMemberInternalCommand.Execute(inputArgs);
                break;

            case "invitetoteam":
                result = InviteToTeamCommand.Execute(inputArgs);
                break;

            case "acceptinvite":
                result = AcceptInviteCommand.Execute(inputArgs);
                break;

            case "declineinvite":
                result = DeclineInvitartionCommand.Execute(inputArgs);
                break;

            case "disband":
                result = DisbandCommand.Execute(inputArgs);
                break;

            case "addteamto":
                result = AddTeamToCommand.Execute(inputArgs);
                break;

            case "exit":
                result = ExitCommand.Execute(inputArgs);
                break;

            default:
                throw new NotSupportedException($"Command {commandName} not supported!");
            }

            return(result);
        }
        public string Dispatch(string input)
        {
            string result = string.Empty;

            string[] inputArgs = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            string commandName = inputArgs.Length > 0 ? inputArgs[0] : string.Empty;

            inputArgs = inputArgs.Skip(1).ToArray();

            switch (commandName)
            {
            case "RegisterUser":
                var registerUser = new RegisterUserCommand();
                result = registerUser.Execute(inputArgs);
                break;

            case "Login":
                var login = new LoginCommand();
                result = login.Execute(inputArgs);
                break;

            case "Logout":
                var logout = new LogoutCommand();
                result = logout.Execute(inputArgs);
                break;

            case "DeleteUser":
                var deleteUser = new DeleteUserCommand();
                result = deleteUser.Execute(inputArgs);
                break;

            case "CreateEvent":
                var createEvent = new CreateEventCommand();
                result = createEvent.Execute(inputArgs);
                break;

            case "CreateTeam":
                var createTeam = new CreateTeamCommand();
                result = createTeam.Execute(inputArgs);
                break;

            case "InviteToTeam":
                var inviteToTeam = new InviteToTeamCommand();
                result = inviteToTeam.Execute(inputArgs);
                break;

            case "AcceptInvite":
                var acceptInvite = new AcceptInviteCommand();
                result = acceptInvite.Execute(inputArgs);
                break;

            case "DeclineInvite":
                var declineInvite = new DeclineInviteCommand();
                result = declineInvite.Execute(inputArgs);
                break;

            case "KickMember":
                var kickMember = new KickMemberCommand();
                result = kickMember.Execute(inputArgs);
                break;

            case "Disband":
                var disband = new DisbandCommand();
                result = disband.Execute(inputArgs);
                break;

            case "AddTeamTo":
                var addTeamTo = new AddTeamToCommand();
                result = addTeamTo.Execute(inputArgs);
                break;

            case "ShowEvent":
                var showEvent = new ShowEventCommand();
                result = showEvent.Execute(inputArgs);
                break;

            case "ShowTeam":
                var showTeam = new ShowTeamCommand();
                result = showTeam.Execute(inputArgs);
                break;

            case "Exit":
                var exit = new ExitCommand();
                exit.Execute(inputArgs);
                break;

            default:
                throw new NotSupportedException($"Command {commandName} not supported!");
            }

            return(result);
        }
        public string Dispatch(string input)
        {
            string result = string.Empty;

            string[] inputArgs = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            string commandName = inputArgs.Length > 0 ? inputArgs[0] : string.Empty;

            inputArgs = inputArgs.Skip(1).ToArray();


            switch (commandName.ToLower())
            {
            case "exit":
                ExitCommand exit = new ExitCommand();
                exit.Execute(inputArgs);
                break;

            case "registeruser":
                RegisterUserCommand registerUser = new RegisterUserCommand();
                result = registerUser.Execute(inputArgs);
                break;

            case "login":
                LoginCommand loginUser = new LoginCommand();
                result = loginUser.Execute(inputArgs);
                break;

            case "logout":
                LogoutCommand logoutUser = new LogoutCommand();
                result = logoutUser.Execute(inputArgs);
                break;

            case "deleteuser":
                DeleteUserCommand deleteUser = new DeleteUserCommand();
                result = deleteUser.Execute(inputArgs);
                break;

            case "createevent":
                CreateEventCommand createEvent = new CreateEventCommand();
                result = createEvent.Execute(inputArgs);
                break;

            case "createteam":
                CreateTeamCommand createTeam = new CreateTeamCommand();
                result = createTeam.Execute(inputArgs);
                break;

            case "showevent":
                ShowEventCommand showEvent = new ShowEventCommand();
                result = showEvent.Execute(inputArgs);
                break;

            case "invitetoteam":
                InviteToTeamCommand inviteToTeam = new InviteToTeamCommand();
                result = inviteToTeam.Execute(inputArgs);
                break;

            case "showteam":
                ShowTeamCommand showTeam = new ShowTeamCommand();
                result = showTeam.Execute(inputArgs);
                break;

            case "acceptinvite":
                AcceptInviteCommand acceptInvite = new AcceptInviteCommand();
                result = acceptInvite.Execute(inputArgs);
                break;

            case "declineinvite":
                DeclineInviteCommand declineInvite = new DeclineInviteCommand();
                result = declineInvite.Execute(inputArgs);
                break;

            case "kickmember":
                KickMemberCommand kickMember = new KickMemberCommand();
                result = kickMember.Execute(inputArgs);
                break;

            case "disband":
                DisbandCommand disband = new DisbandCommand();
                result = disband.Execute(inputArgs);
                break;

            case "addteamto":
                AddTeamToCommand addTeamTo = new AddTeamToCommand();
                result = addTeamTo.Execute(inputArgs);
                break;

            default:
                throw new NotSupportedException($"Command {commandName} not supported!");
            }

            return(result);
        }
Ejemplo n.º 6
0
        public string DispatchCommand(string[] commandParameters)
        {
            string commandName = commandParameters[0];

            commandParameters = commandParameters.Skip(1).ToArray();

            string result = string.Empty;

            switch (commandName)
            {
            case "RegisterUser":
                RegisterUserCommand registerUser = new RegisterUserCommand(new UserService());
                result = registerUser.Execute(commandParameters);
                break;

            case "Login":
                LoginCommand loginCommand = new LoginCommand(new UserService());
                result = loginCommand.Execute(commandParameters);
                break;

            case "Logout":
                LogoutCommand logoutCommand = new LogoutCommand(new UserService());
                result = logoutCommand.Execute(commandParameters);
                break;

            case "DeleteUser":
                DeleteUserCommand deleteUser = new DeleteUserCommand(new UserService());
                result = deleteUser.Execute(commandParameters);
                break;

            case "CreateEvent":
                CreateEventCommand createEvent = new CreateEventCommand(new EventService());
                result = createEvent.Execute(commandParameters);
                break;

            case "CreateTeam":
                CreateTeamCommand createTeam = new CreateTeamCommand(new TeamService());
                result = createTeam.Execute(commandParameters);
                break;

            case "InviteToTeam":
                InviteToTeamCommand invToTeam = new InviteToTeamCommand(new TeamService(), new UserService());
                result = invToTeam.Execute(commandParameters);
                break;

            case "AcceptInvite":
                AcceptInviteCommand acceptInvite = new AcceptInviteCommand(new TeamService(), new UserService());
                result = acceptInvite.Execute(commandParameters);
                break;

            case "DeclineInvite":
                DeclineInviteCommand declineInvite = new DeclineInviteCommand(new TeamService(), new UserService());
                result = declineInvite.Execute(commandParameters);
                break;

            case "KickMember":
                KickMemberCommand kickMember = new KickMemberCommand(new TeamService(), new UserService());
                result = kickMember.Execute(commandParameters);
                break;

            case "Disband":
                DisbandCommand disbandTeam = new DisbandCommand(new TeamService(), new UserService());
                result = disbandTeam.Execute(commandParameters);
                break;

            case "AddTeamTo":
                AddTeamToCommand addTeam = new AddTeamToCommand(new EventService(), new TeamService());
                result = addTeam.Execute(commandParameters);
                break;

            case "ShowEvent":
                ShowEventCommand showEvent = new ShowEventCommand(new EventService());
                result = showEvent.Execute(commandParameters);
                break;

            case "ShowTeam":
                ShowTeamCommand showTeam = new ShowTeamCommand(new TeamService());
                result = showTeam.Execute(commandParameters);
                break;

            case "ImportUsers":
                ImportUsersCommand importUsers = new ImportUsersCommand(new UserService());
                result = importUsers.Execute(commandParameters);
                break;

            case "ImportTeams":
                ImportTeamsCommand importTeams = new ImportTeamsCommand(new TeamService());
                result = importTeams.Execute(commandParameters);
                break;

            case "ExportTeam":
                ExportTeamCommand exportTeam = new ExportTeamCommand(new TeamService());
                result = exportTeam.Execute(commandParameters);
                break;

            case "Exit":
                ExitCommand exit = new ExitCommand();
                exit.Execute(commandParameters);
                break;

            default:
                throw new NotSupportedException($"Command {commandName} not valid!");
            }

            return(result);
        }
Ejemplo n.º 7
0
        public string Dispatch(string input)
        {
            string result = string.Empty;

            string[] inputArgs = Regex.Split(input.Trim(), @"\s+");
            //string[] args = input.Trim().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            string commandName = inputArgs.Length > 0 ? inputArgs[0] : string.Empty;

            inputArgs = inputArgs.Skip(1).ToArray();

            switch (commandName)
            {
            // Basic Logic
            case "RegisterUser":
                RegisterUserCommand register = new RegisterUserCommand();
                result = register.Execute(inputArgs);
                break;

            case "Login":
                LoginCommand login = new LoginCommand();
                result = login.Execute(inputArgs);
                break;

            case "Logout":
                LogoutCommand logout = new LogoutCommand();
                result = logout.Execute(inputArgs);
                break;

            case "DeleteUser":
                DeleteUserCommand deleteUser = new DeleteUserCommand();
                result = deleteUser.Execute(inputArgs);
                break;

            case "Exit":
                ExitCommand exit = new ExitCommand();
                result = exit.Execute(inputArgs);
                break;

            // Advanced Logic
            case "CreateEvent":
                CreateEventCommand createEvent = new CreateEventCommand();
                result = createEvent.Execute(inputArgs);
                break;

            case "CreateTeam":
                CreateTeamCommand createTeam = new CreateTeamCommand();
                result = createTeam.Execute(inputArgs);
                break;

            case "InviteToTeam":
                InviteToTeamCommand inviteToTeam = new InviteToTeamCommand();
                result = inviteToTeam.Execute(inputArgs);
                break;

            case "AcceptInvite":
                AcceptInviteCommand acceptInvite = new AcceptInviteCommand();
                result = acceptInvite.Execute(inputArgs);
                break;

            case "DeclineInvite":
                DeclineInviteCommand declineInvite = new DeclineInviteCommand();
                result = declineInvite.Execute(inputArgs);
                break;

            case "KickMember":
                KickMemberCommand kickMember = new KickMemberCommand();
                result = kickMember.Execute(inputArgs);
                break;

            case "Disband":
                DisbandTeamCommand disband = new DisbandTeamCommand();
                result = disband.Execute(inputArgs);
                break;

            case "AddTeamTo":
                AddTeamToCommand addTeamTo = new AddTeamToCommand();
                result = addTeamTo.Execute(inputArgs);
                break;

            case "ShowEvent":
                ShowEventCommand showEvent = new ShowEventCommand();
                result = showEvent.Execute(inputArgs);
                break;

            case "ShowTeam":
                ShowTeamCommand showTeam = new ShowTeamCommand();
                result = showTeam.Execute(inputArgs);
                break;

            // Import Data
            case "ImportUsers":
                ImportUsersCommand importUsers = new ImportUsersCommand();
                result = importUsers.Execute(inputArgs);
                break;

            case "ImportTeams":
                ImportTeamsCommand importTeams = new ImportTeamsCommand();
                result = importTeams.Execute(inputArgs);
                break;

            // Export Data
            case "ExportTeam":
                ExportTeamCommand exportTeam = new ExportTeamCommand();
                result = exportTeam.Execute(inputArgs);
                break;

            // Basic Logic
            default:
                throw new NotSupportedException($"Command {commandName} not supported!");
            }

            return(result);
        }