public string DispatchCommand(IList <string> data) { var commandName = data[0].ToLower(); var result = string.Empty; switch (commandName) { case "print-info": var printInfoCommand = new PrintInfoCommand(); data.RemoveAt(0); result = printInfoCommand.Execute(data); break; case "buy-ticket": var buyTicketCommand = new BuyTicketCommand(); data.RemoveAt(0); result = buyTicketCommand.Execute(data); break; case "publish-review": var publishReviewCommand = new PublishReviewCommand(); data.RemoveAt(0); result = publishReviewCommand.Execute(data); break; case "print-review": var printReviewCommand = new PrintReviewCommand(); data.RemoveAt(0); result = printReviewCommand.Execute(data); break; case "exit": Environment.Exit(0); break; default: throw new ArgumentException("Invalid Command"); } return(result); }
public string DispatchCommand(string[] commandParams) { string commandName = commandParams[0]; var commandArg = commandParams.Skip(1).ToArray(); string result = string.Empty; switch (commandName) { case "print-info": var printInfo = new PrintInfoCommand(); result = printInfo.Execute(commandArg); break; case "buy-ticket": var buyTicket = new BuyTicketCommand(); result = buyTicket.Execute(commandArg); break; case "publish-review": var publishReview = new PublishReviewCommand(); result = publishReview.Execute(commandArg); break; case "print-reviews": var printReview = new PrintReviewsCommand(); result = printReview.Execute(commandArg); break; case "ChangeTripStatus": var changeTripStatusCommand = new ChangeTripStatusCommand(); result = changeTripStatusCommand.Execute(commandArg); break; default: throw new InvalidOperationException("Invalid command!"); } return(result); }
public string DispatchCommand(string[] cmdParams) { string command = cmdParams[0].ToLower(); string[] data = cmdParams.ToArray(); string result = ""; switch (command) { case "print-info": result = PrintInfoCommand.Execute(cmdParams); break; case "buy-ticket": result = BuyTicketCommand.Execute(cmdParams); break; case "publish-review": result = PublishReviewCommand.Execute(cmdParams); break; case "print-reviews": result = PrintReviewCommand.Execute(cmdParams); break; case "exit": result = ExitCommand.Execute(); break; case "change-trip-status": result = ChangeTripStatusCommand.Execute(cmdParams); break; default: result = "Invalid Command!"; break; } return(result); }
public string DispatchCommand(string[] commandParameters) { string command = commandParameters[0]; string result = null; switch (command.ToLower()) { case "print-info": result = PrintInfoCommand.Execute(commandParameters); break; case "buy-ticket": result = BuyTicketCommand.Execute(commandParameters); break; case "publish-review": result = PublishReviewCommand.Execute(commandParameters); break; case "print-reviews": result = PrintReviewsCommand.Execute(commandParameters); break; case "change-trip-status": result = ChangeTripStatusCommand.Execute(commandParameters); break; case "exit": result = ExitCommand.Execute(commandParameters); break; default: throw new InvalidOperationException($"Command {command} not valid!"); } return(result); }