private byte CheckAndReturnPosition(TableElement element) { byte input; if (element == TableElement.row) { do { input = IO_Handler.EnterByte("Please, enter the number of rows: "); if (input < 1 || input > OwnerAuditorium.Rows) { IO_Handler.ErrorMessage($"Invalid input. Pick from range [1-{OwnerAuditorium.Rows}]"); } } while (input < 1 || input > OwnerAuditorium.Rows); } else if (element == TableElement.column) { do { input = IO_Handler.EnterByte("Please, enter the number of columns: "); if (input < 1 || input > OwnerAuditorium.Columns) { IO_Handler.ErrorMessage($"Invalid input. Pick from range [1-{OwnerAuditorium.Columns}]"); } } while (input < 1 || input > OwnerAuditorium.Columns); } else { throw new InvalidOperationException("There's no such TableElement! Where the hell did you get that from???"); } return((byte)(input - 1)); }
public void FreeSeat() { #region debug message #if DEBUG Program.LogThisCaller(); #endif #endregion byte row = CheckAndReturnPosition(TableElement.row); byte col = CheckAndReturnPosition(TableElement.column); if (GetSeatAvailability(row, col) == Seat.UnAvailable) { FlipSeatAvailabilty(row, col); ReservedSeatsCount--; } else { IO_Handler.ErrorMessage("Still free!"); } }
} //Not implemented in PresentationLayer, so become obsolete: private Projection ReturnProjectionByName() { #region debug message #if DEBUG IO_Handler.LogItsCaller(); #endif #endregion string projectionName = ""; while (!OwnProjections.ContainsKey(projectionName)) { projectionName = IO_Handler.EnterString("Name of the movie you are looking for: ").ToUpper(); if (!OwnProjections.ContainsKey(projectionName)) { IO_Handler.ErrorMessage($"There is no such Projection in this Auditorium No#{Id} with the given name!"); Console.WriteLine("Please, pick one from the following:"); IO_Handler.PrintCollection(OwnProjections.Keys); } } Projection Result = OwnProjections[projectionName]; IO_Handler.SuccessMessage("Projection found!"); return(Result); } //Not implemented in PresentationLayer, so become obsolete:
public void AddNewProjection() { #region debug message #if DEBUG IO_Handler.LogItsCaller(); #endif #endregion if (OwnProjections.Count < 5) { string movieName = IO_Handler.EnterString($"{OwnerCinema}/{this}:\n" + $"Enter the name of the movie beeing projected: ").ToUpper(); if (OwnProjections.ContainsKey(movieName)) { throw new OperationCanceledException("Operation canceled: This movie has already beeing projected here!"); } byte movieLength = IO_Handler.EnterByte("Enter the length of this movie in minutes: "); Movie currentMovie = new Movie(movieName, movieLength); TestAndCreate(currentMovie); } else { IO_Handler.ErrorMessage("Projection Limit Reached"); } }
bool ControlMenu(MenuItem[] MenuItems) { #region debug message #if DEBUG IO_Handler.LogItsCaller(); #endif #endregion bool invalid = true; while (invalid) { ConsoleKey ck = Console.ReadKey(false).Key; switch (ck) { case ConsoleKey.UpArrow: if (--index == -1) { index = MenuItems.Length - 1; } goto case ConsoleKey.Clear; case ConsoleKey.DownArrow: if (++index == MenuItems.Length) { index = 0; } goto case ConsoleKey.Clear; case ConsoleKey.PageDown: index = MenuItems.Length - 1; goto case ConsoleKey.Clear; case ConsoleKey.PageUp: index = 0; goto case ConsoleKey.Clear; case ConsoleKey.Enter: Console.Clear(); try { StackFrame sf = new StackFrame(2); string caller_lvl2 = sf.GetMethod().Name; if (caller_lvl2.Equals("InCinemaMenu")) { try { activeAuditorium = activeCinema.OwnAuditoriums[(byte)(index + 1)]; #region DEBUG #if DEBUG IO_Handler.SuccessMessage("ACTIVE AUDITORIUM GOT SET NOW!"); Thread.Sleep(800); #endif #endregion } catch (Exception e) { IO_Handler.ErrorMessage($"active auditorium not set:\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } } if (caller_lvl2.Equals("InProjectionMenu")) { try { activeProjection = activeAuditorium.OwnProjections.Skip(index).First().Value; } catch (Exception e) { IO_Handler.ErrorMessage($"active projection not set:\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } } GetThisMenuMethods()[index](); } catch (Exception e) { IO_Handler.ErrorMessage($"Error while opening this menu!\nLOC-{(new StackFrame(1, true)).GetFileLineNumber()}\n" + e.Message); Thread.Sleep(sleepTime); } goto case ConsoleKey.Clear; case ConsoleKey.Escape: index = 0; return(false); case ConsoleKey.Clear: return(true); default: invalid = true; break; } } return(true); }