private static void ExecuteCommand(string[] args) { if (args.Length < 2) { ShowUsage(); return; } var baseUrl = args[0]; var command = args[1]; switch (command) { case "LOGIN": if (args.Length < 4) { Console.WriteLine("Invalid parameters for command LOGIN"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var username = args[2]; var password = args[3]; string tokenSession = _webApiClient.Login(username, password); _webApiClient.Token = tokenSession; Console.WriteLine("Token" + tokenSession); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "REGISTER": if (args.Length < 7) { Console.WriteLine("Invalid parameters for command REGISTER"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var username = args[2]; var password = args[3]; var firstname = args[4]; var lastname = args[5]; var emailAddress = args[6]; Console.WriteLine(_webApiClient.Register(username, password, firstname, lastname, emailAddress)); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "GETLISTS": try { Console.WriteLine(_webApiClient.GetAllLists()); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "GETDETAILS": try { var id = args[2]; Console.WriteLine(_webApiClient.GetDetails(Convert.ToInt32(id))); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "CREATELIST": if (args.Length < 4) { Console.WriteLine("Invalid parameters for command CREATELIST"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var name = args[2]; DateTime createDate = Convert.ToDateTime(args[3]); Console.WriteLine(_webApiClient.CreateList(name, createDate)); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "UPDATELIST": if (args.Length < 5) { Console.WriteLine("Invalid parameters for command UPDATELIST"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var idList = args[2]; var name = args[3]; DateTime createDate = DateTime.Now; //args[4]; Console.WriteLine(_webApiClient.UpdateList(Convert.ToInt32(idList), name, createDate)); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "REMOVELIST": if (args.Length < 3) { Console.WriteLine("Invalid parameters for command REMOVELIST"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var idList = args[2]; Console.WriteLine(_webApiClient.RemoveList(Convert.ToInt32(idList))); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "CREATETASK": if (args.Length < 6) { Console.WriteLine("Invalid parameters for command CREATETASK"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var listId = args[2]; var text = args[3]; var iscompleted = Convert.ToBoolean(args[4]); DateTime createDate = Convert.ToDateTime(args[5]); Console.WriteLine(_webApiClient.CreateTask(Convert.ToInt32(listId), text, iscompleted, createDate, null)); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "REMOVETASK": if (args.Length < 4) { Console.WriteLine("Invalid parameters for command REMOVETASK"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var idList = args[2]; var idTask = args[3]; Console.WriteLine(_webApiClient.RemoveTask(Convert.ToInt32(idList), Convert.ToInt32(idTask))); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; case "UPDATETASK": if (args.Length < 8) { Console.WriteLine("Invalid parameters for command UPDATETASK"); ShowCommandUsage(command); } if (args[2] == "/h") { ShowCommandUsage(command); return; } try { var listId = args[2]; var taskId = args[3]; var text = args[4]; var iscompleted = Convert.ToBoolean(args[5]); DateTime createDate = Convert.ToDateTime(args[6]); Console.WriteLine(_webApiClient.UpdateTask(Convert.ToInt32(listId), Convert.ToInt32(taskId), text, iscompleted, createDate, null)); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex); } return; default: Console.WriteLine("Invalid command"); ShowUsage(); return; } }