private static void RemoveEval(IEvalService client) { Console.WriteLine(); Console.Write("ID: "); var inp = Console.ReadLine(); client.RemoveEval(inp); Console.ReadKey(); }
static void Main(string[] args) { WebChannelFactory <IEvalService> cf = new WebChannelFactory <IEvalService>( new Uri("http://localhost:8089/evalservice")); IEvalService client = cf.CreateChannel(); while (true) { Console.WriteLine("[submit]"); Console.WriteLine("[get]"); Console.WriteLine("[list]"); Console.WriteLine("[remove]"); Console.WriteLine("[exit]"); Console.WriteLine("Enter a commando >> "); string comm = Console.ReadLine(); switch (comm) { case "submit": // getting all the required fields for the new eval to create Console.WriteLine("Who is the subbmitter? >> "); string submter = Console.ReadLine(); Console.WriteLine("enter comments in one string >> "); string comments = Console.ReadLine(); Console.WriteLine("Enter an unique id for the EVAL >> "); string id = Console.ReadLine(); // creating the EVAL Eval e = new Eval() { Comments = comments, Submitter = submter, TimeSent = DateTime.Now, Id = id, }; // subbmitting the new eval client.SubmitEval(e); Console.WriteLine("Created!"); break; case "get": Console.WriteLine("enter a id"); string input = Console.ReadLine(); Eval retrieved = client.GetEval(input); if (retrieved != null) { Console.WriteLine("Entered: "); Console.WriteLine(retrieved.Comments + ' ' + retrieved.Submitter); } else { Console.WriteLine("No Eval matching id: " + input); } break; case "list": Console.WriteLine("Enter a subbmitter >>"); string submitterInput = Console.ReadLine(); List <Eval> retrievedEvals = client.GetEvalsBySybmitter(submitterInput); if (retrievedEvals.Count != 0 || retrievedEvals == null) { foreach (var ev in retrievedEvals) { Console.WriteLine(ev.Submitter + " " + ev.Comments); Console.WriteLine("------------"); } } break; case "remove": Console.WriteLine("Id to remove >> "); string removeId = Console.ReadLine(); client.RemoveEval(removeId); break; default: Console.WriteLine("Command is not supported!"); break; } if (comm == "exit") { break; } Console.ReadKey(); } Console.WriteLine("exiting program"); }
static void Main(string[] args) { WebChannelFactory <IEvalService> cf = new WebChannelFactory <IEvalService>( new Uri("http://localhost:8080/EvalService")); IEvalService client = cf.CreateChannel(); Console.WriteLine("Please enter one of following commands."); Console.WriteLine("submit"); Console.WriteLine("get"); Console.WriteLine("list"); Console.WriteLine("remove"); Console.WriteLine("exit"); var command = Console.ReadLine(); while (command != "Exit") { switch (command) { case "submit": Console.WriteLine("Enter comment"); var comment = Console.ReadLine(); Console.WriteLine("Enter Submitter"); var submitter = Console.ReadLine(); var eval = new Eval() { Comment = comment, Submitter = submitter, TimeSent = DateTime.Now }; client.SubmitEval(eval); Console.WriteLine("eval submitted"); command = null; break; case "get": Console.WriteLine("Enter a Eval ID:"); var evalId = Console.ReadLine(); var gottenEval = client.GetEval(evalId); Console.WriteLine((gottenEval != null) ? $" {gottenEval.Id}. {gottenEval.Submitter} said { gottenEval.Comment }" : "No Eval found"); Console.ReadLine(); command = null; break; case "list": Console.WriteLine("Enter name of submitter"); var submitterName = Console.ReadLine(); //if (!string.IsNullOrWhiteSpace(submitterName)) //{ var evalsBySubmitter = client.GetEvalBySubmitter(submitterName); if (evalsBySubmitter != null) { evalsBySubmitter.ForEach(e => Console.WriteLine($" {e.Id}. {e.Submitter} said { e.Comment }")); } else { Console.WriteLine("No Evals found by {0}", submitterName); } //} //else //{ // Console.WriteLine("Invalid input!"); //} Console.ReadLine(); command = null; break; case "remove": Console.WriteLine("Enter Id to remove Eval"); var idToRemove = Console.ReadLine(); client.RemoveEval(idToRemove); break; case "exit": Environment.Exit(-1); break; } Console.Clear(); Console.WriteLine("Please enter one of following commands."); Console.WriteLine("submit"); Console.WriteLine("get"); Console.WriteLine("list"); Console.WriteLine("remove"); Console.WriteLine("exit"); command = Console.ReadLine(); } }
static void Main(string[] args) { Console.WriteLine("*** Evaluation Client Application ***\n"); //EvalServiceClient client = // new EvalServiceClient("BasicHttpBinding_IEvalService"); WebChannelFactory <IEvalService> cf = new WebChannelFactory <IEvalService>( new Uri("http://localhost:8080/evalservice")); IEvalService client = cf.CreateChannel(); Console.WriteLine("Please enter a command: "); string command = Console.ReadLine(); while (!command.Equals("exit")) { switch (command) { case "submit": Console.WriteLine("Please enter your name:"); string name = Console.ReadLine(); Console.WriteLine("Please enter your comments:"); string comments = Console.ReadLine(); Eval eval = new Eval(); eval.Timesent = DateTime.Now; eval.Submitter = name; eval.Comments = comments; client.SubmitEval(eval); Console.WriteLine("Evaluation submitted!\n"); break; case "get": Console.WriteLine("Please enter the eval id:"); string id = Console.ReadLine(); Eval fe = client.GetEval(id); Console.WriteLine("{0} -- {1} said: {2} (id {3})\n", fe.Timesent, fe.Submitter, fe.Comments, fe.Id); break; case "list": Console.WriteLine("Please enter the submitter name:"); name = Console.ReadLine(); List <Eval> evals = client.GetEvalsBySubmitter(name); evals.ForEach(e => Console.WriteLine("{0} -- {1} said: {2} (id {3})", e.Timesent, e.Submitter, e.Comments, e.Id)); Console.WriteLine(); break; case "remove": Console.WriteLine("Please enter the eval id:"); id = Console.ReadLine(); client.RemoveEval(id); Console.WriteLine("Evaluation {0} removed!\n", id); break; default: Console.WriteLine("Unsupported command."); break; } Console.WriteLine("Please enter a command: "); command = Console.ReadLine(); } }