Example #1
0
        public string Dispatch(string input)
        {
            string result = String.Empty;

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

            string cmdName = args.Length >= 0 ? args[0] : string.Empty;

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

            switch (cmdName)
            {
            case "RegisterUser": result = new RegisterUserCommand().Execute(args); break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return(result);
        }
Example #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[] { ' ', '\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);
        }
Example #4
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);
        }
        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);
        }
        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":
                RegisterUserCommand registerCmd = new RegisterUserCommand();
                result = registerCmd.Execute(inputArgs);
                break;

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

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

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

            //try to make description as a one argument
            case "CreateEvent":
                CreateEventCommand createEventCmd = new CreateEventCommand();
                result = createEventCmd.Execute(inputArgs);
                break;

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

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

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

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

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

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

//                case "AddTeamTo":
//                    AddTeamToEventCommand addTeamToCmd = new AddTeamToEventCommand();
//                    result = addTeamToCmd.Execute(inputArgs);
//                    break;
            case "ShowEvent":
                ShowEventCommand showEventCmd = new ShowEventCommand();
                result = showEventCmd.Execute(inputArgs);
                break;

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

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

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

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

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

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

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

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

            case "RegisterUser":
                result = new RegisterUser().Execute(commandArgs);
                break;

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

            case "CreateEvent":
                commandArgs = new[] { commandArgs[0], commandArgs[1], $"{commandArgs[2]} {commandArgs[3]}", $"{commandArgs[4]} {commandArgs[5]}" };
                result      = new CreateEventCommand().Execute(commandArgs);
                break;

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

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

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

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

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

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

            case "AddTeamTo":
                result = new AddToTeamCommand().Execute(commandArgs);
                break;

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

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

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

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

            return(result);
        }
Example #8
0
        public static string Dispatch(string input)
        {
            string result = "";

            string[] inputArgs = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            var      command   = inputArgs.Length > 0 ? inputArgs[0].ToLower() : string.Empty;

            string[] data = inputArgs.Skip(1).ToArray();

            switch (command)
            {
            case "exit":
                result = Exitcommand.Execute(data);
                break;

            case "registeruser":
                result = RegisterUserCommand.Execute(data);
                break;

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

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

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

            case "createevent":
                result = CreateEventCommand.Execute(data);
                break;

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

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

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

            case "declaneinvite":
                result = DeclineInviteCommand.Execute(data);
                break;

            case "kickmember":
                result = KickMemberCommand.Execute(data);
                break;

            case "disbandteam":
                result = DisbandTeamCommand.Execute(data);
                break;

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

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

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

            default:
                throw new NotSupportedException($"Command {command} not valid!");
            }
            return(result);
        }
Example #9
0
        public string Dispatch(string input)
        {
            string result = string.Empty;

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

            //Ako sme podali parametri znachi imeto na komandata e urviq parametur ako nqma znachi imeto e prazen string !
            string commandName = inputArgs.Length > 0 ? inputArgs[0] : string.Empty;

            //Mahame imeto i ostavat samo parametrite
            inputArgs = inputArgs.Skip(1).ToArray();


            switch (commandName)
            {
            case "Exit":
                ExitCommand exit = new ExitCommand();
                result = exit.Excecute(inputArgs);
                break;

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

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

            case "RegisterUser":
                RegisterUserCommand registerUser = new RegisterUserCommand();
                result = registerUser.Excecute(inputArgs);
                break;

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

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

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

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

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

            case "AddTeamTo":
                AddTeamToCommand addTeamToCommand = new AddTeamToCommand();
                result = addTeamToCommand.Excecute(inputArgs);
                break;

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

            case "AcceptInvite":
                AcceptInviteCommand acceptInviteCommand = new AcceptInviteCommand();
                result = acceptInviteCommand.Excecute(inputArgs);
                break;

            case "DeclineInvite":
                DeclineInviteCommand declinetInvite = new DeclineInviteCommand();
                result = declinetInvite.Excecute(inputArgs);
                break;

            case "KickMember":
                KickMemberCommand kickMemberCommand = new KickMemberCommand();
                result = kickMemberCommand.Excecute(inputArgs);
                break;

            case "DisbandTeam":
                DisbandTeamCommand disbandTeamCommand = new DisbandTeamCommand();
                result = disbandTeamCommand.Excecute(inputArgs);
                break;

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

            return(result);
        }
Example #10
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);
        }
Example #11
0
        public string Dispatch(string input)
        {
            string result = string.Empty;

            var    inputArgs = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            string command   = inputArgs.Length > 0 ? inputArgs[0] : string.Empty;

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

            switch (command.ToLower())
            {
            case "registeruser": result = new RegisterUserCommand().Execute(commandArgs);
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

            return(result);
        }
Example #12
0
        public string Dispatch(string input)
        {
            string output = String.Empty;

            string[] inputArgs   = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            string   commandName = inputArgs.Length > 0 ? inputArgs[0] : String.Empty;

            string[] commandArgs = inputArgs.Skip(1).ToArray();
            ICommand command     = null;

            switch (commandName)
            {
            case "AcceptInvite":
                command = new AcceptInviteCommand(serviceProvider);
                break;

            case "AddTeamTo":
                command = new AddTeamToCommand(serviceProvider);
                break;

            case "CreateEvent":
                command = new CreateEventCommand(serviceProvider);
                break;

            case "CreateTeam":
                command = new CreateTeamCommand(serviceProvider);
                break;

            case "DeclineInvite":
                command = new DeclineInviteCommand(serviceProvider);
                break;

            case "DeleteUser":
                command = new DeleteUserCommand(serviceProvider);
                break;

            case "Disband":
                command = new DisbandCommand(serviceProvider);
                break;

            case "Exit":
                command = new ExitCommand();
                break;

            case "InviteToTeam":
                command = new InviteToTeamCommand(serviceProvider);
                break;

            case "KickMember":
                command = new KickMemberCommand(serviceProvider);
                break;

            case "Login":
                command = new LoginCommand(serviceProvider);
                break;

            case "Logout":
                command = new LogoutCommand(serviceProvider);
                break;

            case "RegisterUser":
                command = new RegisterUserCommand(serviceProvider);
                break;

            case "ShowEvent":
                command = new ShowEventCommand(serviceProvider);
                break;

            case "ShowTeam":
                command = new ShowTeamCommand(serviceProvider);
                break;

            default:
                throw new NotSupportedException(String.Format(Messages.CommandNotSupported, commandName));
            }
            output = command.Execute(commandArgs);
            return(output);
        }
        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);
        }