private void Select(string parameters) { var isNoRecordsFound = false; parameters = parameters.ToUpperInvariant(); IEnumerable <FileCabinetRecord> selectedRecords = new List <FileCabinetRecord>(); List <string> displayedFieldsCollection; if (this.TrySelectRecordsWithoutProperties(parameters, out displayedFieldsCollection)) { selectedRecords = this.fileCabinetService.GetRecords().ToList(); isNoRecordsFound = !selectedRecords.Any(); } else if (this.TrySelectRecordsWithProperties(parameters, out displayedFieldsCollection, out List <string> propertiesSignList, out List <Tuple <string, object> > propertiesList)) { ReadOnlyCollection <Tuple <string, object> > readonlyPropertyList = new ReadOnlyCollection <Tuple <string, object> >(propertiesList); ReadOnlyCollection <string> readOnlyPropertySignsList = new ReadOnlyCollection <string>(propertiesSignList); SearchProperties searchProperties = new SearchProperties(readonlyPropertyList, readOnlyPropertySignsList); if (!(searchProperties is null)) { selectedRecords = Memoizer.GetMemoizer(this.fileCabinetService).Select(searchProperties); isNoRecordsFound = !selectedRecords.Any(); } } if (selectedRecords.Any()) { TablePrinter.Print(selectedRecords.OrderBy(record => record.Id), displayedFieldsCollection); Console.WriteLine(); return; } else if (isNoRecordsFound) { Console.WriteLine("Records with this criteria not found."); Console.WriteLine(); return; } Console.WriteLine(HintMessage); Console.WriteLine(); }
static void PrintTable <T>(Table <T> table) where T : DB.Row, new() { PrintFunc(typeof(T).FullName); var colHeaders = new List <string>(); table.Cols.ForEach(x => colHeaders.Add(x.Name)); var printer = new TablePrinter(); printer.SetHeaders(colHeaders.ToArray()); foreach (var row in table.Rows) { var cols = new List <string>(); table.Cols.ForEach(x => cols.Add(row.GetValueString(x))); printer.AddRow(cols.ToArray()); } Console.WriteLine(printer.ToString()); }
static void GetFilmById() { int id = GetId(); if (id < 0) { return; } Film film = database.films.Get(id); if (film != null) { TablePrinter <Film> .Print(film); } else { Console.WriteLine("NO RECORD"); } }
public void ExecuteEnt() { DateTime inicio, fim; List <string> prms = new List <string>(); prms = InfoGetter(prms); try { inicio = Convert.ToDateTime(prms[0]); fim = Convert.ToDateTime(prms[1]); } catch (FormatException) { Console.WriteLine("Alguns parametros estavam errados."); return; } using (var ctx = new SoAventuraEntities()) { try { var CanceledEvents = ctx.EventosDisponiveis(inicio, fim).ToList(); ctx.SaveChanges(); var colunas = typeof(EventosDisponiveis_Result).GetProperties().Select(prop => prop.Name).ToList(); TablePrinter.PrintTable(colunas); CanceledEvents.ForEach(eq => Console.WriteLine(eq.Id_Evento + " - " + eq.ano)); Console.WriteLine("Listagem dos eventos Disponiveis."); } catch (Exception e) { Console.WriteLine(e.InnerException.Message); return; } } }
static void DeleteActor() { int id = GetId(); if (id < 0) { return; } Actor result = database.actors.Delete(id); database.Save(); if (result != null) { Console.WriteLine("DELETE"); TablePrinter <Actor> .Print(result); } else { Console.WriteLine("NO RECORD"); } }
static void DeleteFilm() { int id = GetId(); if (id < 0) { return; } Film film = database.films.Delete(id); database.Save(); if (film != null) { Console.WriteLine("DELETE"); TablePrinter <Film> .Print(film); } else { Console.WriteLine("NO RECORD"); } }
static void DeleteGenre() { int id = GetId(); if (id < 0) { return; } Genre genre = database.genres.Delete(id); database.Save(); if (genre != null) { Console.WriteLine("DELETE"); TablePrinter <Genre> .Print(genre); } else { Console.WriteLine("NO RECORD"); } }
public void Print() { /* Test for table output to console */ using (StringWriter stringWriter = new StringWriter()) { Console.SetOut(stringWriter); using (StringReader stringReader = new StringReader(string.Empty)) { Console.SetIn(stringReader); List <int> primeNumbers = new List <int> { 2, 3, 5 }; TablePrinter.Print(primeNumbers); var expectedOutput = "\t2\t3\t5\t" + Environment.NewLine + "2\t4\t6\t10\t" + Environment.NewLine + "3\t6\t9\t15\t" + Environment.NewLine + "5\t10\t15\t25\t" + Environment.NewLine; Assert.AreEqual <string>(expectedOutput, stringWriter.ToString()); } } }
public override void Display() { base.Display(); if (SessionManager.IsAdmin()) { Console.BackgroundColor = ConsoleColor.Blue; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.BackgroundColor = ConsoleColor.Black; } else { Console.BackgroundColor = ConsoleColor.Magenta; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Black; } /* * Get data from the Database */ try { Output.WriteLine("FILM LIST: "); TablePrinter.Film(SessionManager.GetServiceClient().GetFilmList()); } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
static void Main(string[] args) { CommandoTextWriter.Use(); Console.WriteLine("\n\nDemo of Commando!\n\n".Magenta().Bold()); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine("1. Tables\n\n".Cyan().Bold()); var t = new TablePrinter("Country", "Capital", "Population"); t.AddRow("Sweden", "Stockholm", "~1,3M"); t.AddRow("Norway", "Oslo", "~900k"); t.AddRow("Finland", "Helsinki", "~600k"); t.AddRow("Denmark", "Copenhagen", "~1,3M"); t.Print(); Console.WriteLine("\n\n"); var t2 = new TablePrinter("Country", "Capital", "Population"); t2.AddRow("Sweden", "Stockholm", "~1,3M"); t2.AddRow("Norway", "Oslo", "~900k"); t2.AddRow("Finland", "Helsinki", "~600k"); t2.AddRow("Denmark", "Copenhagen", "~1,3M"); t2.AddFooter("Total", "", "~4,1M"); t2.Print(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine("\n\n2. Pretty print\n\n".Cyan().Bold()); var p = new PrettyPrinter(); p.Add("Sweden", "Stockholm"); p.Add("Norway", "Oslo"); p.Add("Finland", "Helsinki"); p.Add("Denmark", "Copenhagen"); p.Print(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine("\n\n3. Prompts\n\n".Cyan().Bold()); var prompt = new SelectPrompt("Choose country"); prompt.Add(new PromptItem("Sweden", "SE")); prompt.Add(new PromptItem("Norway", "NO")); prompt.Add(new PromptItem("Finland", "FI")); prompt.Add(new PromptItem("Denmark", "DK")); var item = prompt.Prompt(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine($"You choosed {item.Name}: {item.Value.ToString()}"); new YesNoQuestion("Is this correct?").Prompt(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); var multiprompt = new MultiSelectPrompt("Choose countries"); multiprompt.Add(new PromptItem("Sweden", "SE")); multiprompt.Add(new PromptItem("Norway", "NO")); multiprompt.Add(new PromptItem("Finland", "FI")); multiprompt.Add(new PromptItem("Denmark", "DK")); var answer = multiprompt.Prompt(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); var username = new Question("Username", QuestionType.Text).Prompt(); var password = new Question("Password", QuestionType.Password).Prompt(); Console.WriteLine("You choosed:"); foreach (var a in answer) { Console.WriteLine(a.Name); } Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine("\n\n4. Progress bar\n\n".Cyan().Bold()); ProgressBar progressBar = new ProgressBar(); progressBar.Set(10, "Initializing"); Thread.Sleep(2000); progressBar.Set(20, "Downloading..."); Thread.Sleep(1000); progressBar.Set(30); Thread.Sleep(100); progressBar.Set(40); Thread.Sleep(1000); progressBar.Set(50, "Building"); Thread.Sleep(100); progressBar.Set(60); Thread.Sleep(100); progressBar.Set(70); Thread.Sleep(1000); progressBar.Set(80, "Creating databases"); Thread.Sleep(1000); progressBar.Set(90, "Finishing"); Thread.Sleep(2000); progressBar.Set(100); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); Console.WriteLine("\n\nt. Font styles\n\n".Cyan().Bold()); p = new PrettyPrinter(); p.Add("Zebra", "Zebra".Zebra()); p.Add("Rainbow", "Rainbow".Rainbow()); p.Add("Bold", "Bold".Bold()); p.Add("Italic", "Italic".Italic()); p.Add("Underline", "Underline".Underline()); p.Add("Inverse", "Inverse".Inverse()); p.Add("Red", "Red".Red()); p.Add("White", "White".White()); p.Add("Grey", "Grey".Grey()); p.Add("Black", "Black".Black()); p.Add("Blue", "Blue".Blue()); p.Add("Cyan", "Cyan".Cyan()); p.Add("Green", "Green".Green()); p.Add("Magenta", "Magenta".Magenta()); p.Add("Red", "Red".Red()); p.Add("Yellow", "Yellow".Yellow()); p.Print(); new YesNoQuestion("Quit?").Prompt(); }
/// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="T:iohmma.MealyIohmm`2"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents the current <see cref="T:iohmma.MealyIohmm`2"/>.</returns> /// <remarks> /// <para>The Hidden Markov Model is formatted as a two-dimensional table with in the x-direction the hidden states /// and in the y-direction the initial probability, the transition probabilities and the emission probabilities.</para> /// </remarks> public override string ToString() { return(TablePrinter.WriteTable(this.Pi.Cast <object> (), this.Transitions, this.emissions)); }
public override void Display() { base.Display(); Console.BackgroundColor = ConsoleColor.Blue; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.BackgroundColor = ConsoleColor.Black; try { /* * Show the user the Film and the Hall List */ Output.WriteLine("LIST OF EVENT ALREADY INSERTED: "); TablePrinter.Event(SessionManager.GetServiceClient().GetEventsList()); Output.WriteLine("FILM LIST:"); TablePrinter.Film(SessionManager.GetServiceClient().GetFilmList()); Console.WriteLine("\nHALL LIST:"); TablePrinter.Hall(SessionManager.GetServiceClient().GetHallsList()); /* * Add Event Form * * Every input must be valid and checked. */ Output.WriteLine("------ ADD NEW EVENT ------- "); string date_time = Input.ReadString("Data and Time of the Event: "); // Navigate back if User type "\\" on first input if (date_time.Contains("\\")) { Program.NavigateBack(); } DateTime dateTime = Controls.CheckDate(date_time); string film_code = Input.ReadString("Code of the Film: "); int filmCode = Controls.CheckIntForeignKey(film_code, "Film"); string hall_code = Input.ReadString("Hall code of the Event: "); int hallCode = Controls.CheckIntForeignKey(hall_code, "Sala"); string _price = Input.ReadString("Insert the Price (ex: 8,50): "); decimal price = Controls.CheckDecimal(_price); /* * Send data to Database */ if (SessionManager.GetServiceClient().AddEvent(SessionManager.GetUser().Username, dateTime, filmCode, hallCode, price)) { Output.WriteLine("\nEVENT INSERTION SUCCESSFUL\n"); } else { Output.WriteLine("\nEVENT INSERTION FAILED!\nCheck that there are no other events at the same time, in the same date and in the same hall!"); } } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
public void Execute(Dictionary <string, string> arguments) { string connectInfo; bool permissions; ArgumentSet argumentSet; try { argumentSet = ArgumentSet.FromDictionary( arguments, new List <string>() { "/server" }); } catch (Exception e) { Console.WriteLine($"[x] Error: {e.Message}"); return; } argumentSet.GetExtraBool("/permissions", out permissions); SqlConnection connection; SQLExecutor.ConnectionInfo(arguments, argumentSet.connectserver, argumentSet.database, argumentSet.sqlauth, out connectInfo); if (String.IsNullOrEmpty(connectInfo)) { return; } if (!SQLExecutor.Authenticate(connectInfo, out connection)) { return; } // I am confused about why it is necessary to perform this step as a separate procedure // But it seems in-line impersonation doesn't work properly if (!String.IsNullOrEmpty(argumentSet.impersonate)) { Console.WriteLine("[*] Attempting impersonation as {0}", argumentSet.impersonate); SQLExecutor.ExecuteProcedure(connection, "", argumentSet.impersonate); } var queries = new List <string>(); queries.Add("SELECT SYSTEM_USER as 'Logged in as', CURRENT_USER as 'Mapped as';"); queries.Add("SELECT IS_SRVROLEMEMBER('public') as 'Public role';"); queries.Add("SELECT IS_SRVROLEMEMBER('sysadmin') as 'Sysadmin role';"); foreach (string query in queries) { if (String.IsNullOrEmpty(argumentSet.target) && String.IsNullOrEmpty(argumentSet.intermediate)) { SQLExecutor.ExecuteQuery( connection, query, argumentSet.impersonate); } else if (String.IsNullOrEmpty(argumentSet.intermediate)) { SQLExecutor.ExecuteLinkedQuery( connection, query, argumentSet.target, argumentSet.impersonate, argumentSet.impersonate_linked ); } else { SQLExecutor.ExecuteDoublyLinkedQuery( connection, query, argumentSet.target, argumentSet.intermediate, argumentSet.impersonate, argumentSet.impersonate_linked, argumentSet.impersonate_intermediate ); } } /* * The following query is quite difficult to wrap within my SQLExecutor, mostly due to the fact I implemented the output in tabular format */ if (permissions) { Console.WriteLine("[*] Checking user permissions.."); string query = @"SELECT * FROM(SELECT 'OBJECT' AS entity_class, NAME, subentity_name, permission_name FROM sys.objects CROSS APPLY fn_my_permissions(QUOTENAME(NAME), 'OBJECT') a UNION ALL SELECT 'DATABASE' AS entity_class, NAME, subentity_name, permission_name FROM sys.databases CROSS APPLY fn_my_permissions(QUOTENAME(NAME), 'DATABASE') a UNION ALL SELECT 'SERVER' AS entity_class, @@SERVERNAME AS NAME, subentity_name, permission_name FROM fn_my_permissions(NULL, 'SERVER')) p ORDER BY entity_class, NAME"; if (!String.IsNullOrEmpty(argumentSet.intermediate) && !String.IsNullOrEmpty(argumentSet.target)) { query = SQLExecutor.PrepareDoublyLinkedQuery( query, argumentSet.target, argumentSet.intermediate, argumentSet.impersonate, argumentSet.impersonate_linked, argumentSet.impersonate_intermediate ); } else if (!String.IsNullOrEmpty(argumentSet.target)) { query = SQLExecutor.PrepareLinkedQuery( query, argumentSet.target, argumentSet.impersonate, argumentSet.impersonate_linked ); } SqlCommand command = new SqlCommand(query, connection); TablePrinter.PrintRow("ENTITY", "NAME", "SUBENTITY", "PERMISSION"); TablePrinter.PrintLine(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { TablePrinter.PrintRow(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3)); } } TablePrinter.PrintLine(); } connection.Close(); }
public override void Display() { base.Display(); Console.BackgroundColor = ConsoleColor.Blue; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.BackgroundColor = ConsoleColor.Black; /* * Change output encoding to allow special * characters output such as € */ Console.OutputEncoding = System.Text.Encoding.UTF8; try { if (SessionManager.GetServiceClient().GetFilmList().Count != 0) { /* * Show the Admin the Film */ Output.WriteLine("FILM LIST: "); TablePrinter.Film(SessionManager.GetServiceClient().GetFilmList()); /* * Delete Film Form * * Every Primary Key input must be valid. */ Output.WriteLine("\n------ DELETE FILM ------- "); string film_code = Input.ReadString("Insert the Code of the Film to delete: "); // Navigate back if User type "\\" on first input if (film_code.Contains("\\")) { Program.NavigateBack(); } int filmCode = Controls.CheckIntForeignKey(film_code, "Film"); /* * Send data to Database */ if (SessionManager.GetServiceClient().DeleteFilm(filmCode)) { Output.WriteLine("\nFILM CANCELLATION SUCCESS!\n"); } else { Output.WriteLine("\nFILM CANCELLATION FAILED! Retry!\n"); } } else { Console.WriteLine("There are no Film in the DataBase!"); } } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
private void CarsList() { int number = 0; bool id = true; bool plate = false; bool manufacturer = false; bool model = false; bool price = false; bool location = false; CarWebService cars = new CarWebService(); while (true) { Console.Clear(); var table = TablePrinter.GetDataInTableFormat(cars.WebServiceCarsList(number)); Console.WriteLine(table); Console.WriteLine("Sort by: _ 1 - Car ID"); Console.WriteLine(" 2 - Plate"); Console.WriteLine(" 3 - Manufacturer"); Console.WriteLine(" 4 - Model"); Console.WriteLine(" 5 - Price Per Day"); Console.WriteLine(" 6 - Location"); Console.WriteLine(" 7 - to Main menu"); number = Utility.InputAndValidatInt(); switch (number) { case 1: if (id == false) { number = 0; id = true; } else { number = 1; id = false; } break; case 2: if (plate == false) { number = 2; plate = true; } else { number = 3; plate = false; } break; case 3: if (manufacturer == false) { number = 4; manufacturer = true; } else { number = 5; manufacturer = false; } break; case 4: if (model == false) { number = 6; model = true; } else { number = 7; model = false; } break; case 5: if (price == false) { number = 8; price = true; } else { number = 9; price = false; } break; case 6: if (location == false) { number = 10; location = true; } else { number = 11; location = false; } break; case 7: GoToMainMenu(); break; default: number = 0; break; } } }
public override void Display() { base.Display(); Console.BackgroundColor = ConsoleColor.Blue; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.BackgroundColor = ConsoleColor.Black; /* * Change output encoding to allow special * characters output such as € */ Console.OutputEncoding = System.Text.Encoding.UTF8; try { /* * Show the Admin the Events */ if (SessionManager.GetServiceClient().GetEventsList().Count != 0) { Output.WriteLine("EVENTS LIST: "); TablePrinter.Event(SessionManager.GetServiceClient().GetEventsList()); /* * Delete Event Form * * Every Primary Key input must be valid. * When a Event is deleted, the Prenotations and the Reservations * linked to it are deleted too. */ Output.WriteLine("\n------ DELETE EVENT ------- "); string event_code = Input.ReadString("Insert the Code of the Event to delete: "); // Navigate back if User type "\\" on first input if (event_code.Contains("\\")) { Program.NavigateBack(); } int eventCode = Controls.CheckIntForeignKey(event_code.ToString(), "Evento"); /* * Send data to Database */ if (SessionManager.GetServiceClient().DeleteEvent(eventCode)) { Output.WriteLine("\nEVENT CANCELLATION SUCCESS!\n"); } else { Output.WriteLine("\nEVENT CANCELLATION FAILED! Retry!\n"); } } else { Console.WriteLine("There are no Events in the DataBase!"); } } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
public override void Display() { base.Display(); Console.BackgroundColor = ConsoleColor.Blue; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.BackgroundColor = ConsoleColor.Black; try { if (SessionManager.GetServiceClient().GetPrenotationsList().Count != 0) { /* * Show the Admin the Prenotations */ Output.WriteLine("PRENOTATIONS LIST: "); TablePrinter.Prenotation(SessionManager.GetServiceClient().GetPrenotationsList()); /* * Delete Film Form * * Every Primary Key input must be valid. * When a Prenotation is deleted the Reservations * linked to it are deleted too. */ Output.WriteLine("\n------ DELETE PRENOTATION ------- "); string prenotation_code = Input.ReadString("Insert the Code of the Prenotation to delete: "); // Navigate back if User type "\\" on first input if (prenotation_code.Contains("\\")) { Program.NavigateBack(); } int prenotationCode = Controls.CheckIntForeignKey(prenotation_code, "Prenotazione"); /* * Send data to Database */ if (SessionManager.GetServiceClient().DeletePrenotation(prenotationCode)) { Output.WriteLine("\nPRENOTATION CANCELLATION SUCCESS!\n"); } else { Output.WriteLine("\nPRENOTATION CANCELLATION FAILED! Retry!\n"); } } else { Console.WriteLine("There are no Prenotations in the DataBase!"); } } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
static void GetAllFilm() { List <Film> films = FilmController.GetAll(); TablePrinter <Film> .Print(films); }
public override void Display() { base.Display(); Console.BackgroundColor = ConsoleColor.Magenta; Output.WriteLine(ConsoleColor.White, "--------== {0} ==--------\n", base.Title); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Black; /* * Change output encoding to allow special * characters output such as € */ Console.OutputEncoding = System.Text.Encoding.UTF8; /* * Show the User the Events */ try { if (SessionManager.GetServiceClient().GetShowsList().Count != 0) { Output.WriteLine("SHOWS LIST: "); TablePrinter.Show(SessionManager.GetServiceClient().GetShowsList()); DateTime dateTime = DateTime.Now; string event_code = Input.ReadString("\nChoose the code of the show you want to buy the ticket: "); // Navigate back if User type "\\" on first input if (event_code.Contains("\\")) { Program.NavigateBack(); } int eventCode = Controls.CheckIntForeignKey(event_code, "Evento"); /* * Show the User the Hall */ Output.WriteLine("Places in the Hall:\n{0}", SessionManager.GetServiceClient().DrawHall(eventCode)); /* * Show the User the available Places */ Output.WriteLine("Available Places:"); TablePrinter.PlaceNumber(SessionManager.GetServiceClient().GetAvailablePlacesList(eventCode)); /* * Let the User choose the place to buy */ string place_number = Input.ReadString("Choose the place you want to buy: "); int place_Number = Controls.CheckInt(place_number); int placeNumber = Controls.CheckPlace(eventCode.ToString(), place_Number.ToString()); /* * Add a New Prenotation */ if (SessionManager.GetServiceClient().AddPrenotation(dateTime, SessionManager.GetUser().Username, eventCode, placeNumber)) { Output.WriteLine("\nYour Prenotation request success!"); } else { Output.WriteLine("\nPrenotation request failed! Retry!"); } } else { Console.WriteLine("There are no Shows in the DB!\n"); } } catch { Console.WriteLine("Error! Retry later!"); } /* * Navigate back */ Input.ReadString("Press [Enter] to navigate back"); Program.NavigateBack(); }
private void ListReservations() { int number = 0; bool plate = true; bool clientId = false; bool start = false; bool end = false; bool location = false; while (true) { Console.Clear(); var table = TablePrinter.GetDataInTableFormat(controller.ReservationsList(number)); Console.WriteLine(table); Console.WriteLine("Sort by: _ 1 - Car plate"); Console.WriteLine(" 2 - Client ID"); Console.WriteLine(" 3 - Start Date"); Console.WriteLine(" 4 - End Date"); Console.WriteLine(" 5 - Location"); Console.WriteLine(" 6 - to Main menu"); number = Utility.InputAndValidatInt(); switch (number) { case 1: if (plate == false) { number = 0; plate = true; } else { number = 1; plate = false; } break; case 2: if (clientId == false) { number = 2; clientId = true; } else { number = 3; clientId = false; } break; case 3: if (start == false) { number = 4; start = true; } else { number = 5; start = false; } break; case 4: if (end == false) { number = 6; end = true; } else { number = 7; end = false; } break; case 5: if (location == false) { number = 8; location = true; } else { number = 9; location = false; } break; case 6: GoToMainMenu(); break; default: number = 0; break; } } }
private void CustomerList() { int number = 0; bool id = true; bool name = false; bool birthDate = false; bool location = false; while (true) { Console.Clear(); var table = TablePrinter.GetDataInTableFormat(controller.CustomerList(number)); Console.WriteLine(table); Console.WriteLine("Sort by: _ 1 - ClientID"); Console.WriteLine(" 2 - Client name"); Console.WriteLine(" 3 - Birth date"); Console.WriteLine(" 4 - Location"); Console.WriteLine(" 5 - to Main menu"); number = Utility.InputAndValidatInt(); switch (number) { case 1: if (id == false) { number = 0; id = true; } else { number = 1; id = false; } break; case 2: if (name == false) { number = 2; name = true; } else { number = 3; name = false; } break; case 3: if (birthDate == false) { number = 4; birthDate = true; } else { number = 5; birthDate = false; } break; case 4: if (location == false) { number = 6; location = true; } else { number = 7; location = false; } break; case 5: GoToMainMenu(); break; default: number = 0; break; } } }