Esempio n. 1
0
        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;
            }

            /*
             * Change output encoding to allow special
             * characters output such as €
             */
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            /*
             * Get data from the Database
             */
            try
            {
                Output.WriteLine("EVENTS LIST: ");
                TablePrinter.Event(SessionManager.GetServiceClient().GetEventsList());
            } catch {
                Console.WriteLine("Error! Retry later!");
            }

            /*
             * Navigate back
             */
            Input.ReadString("Press [Enter] to navigate back");
            Program.NavigateBack();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
        }