Esempio n. 1
0
        public static void UIForConsoleApp()
        {
            ConsoleKeyInfo   info;
            PersonRepository personRepository = new PersonRepository();

            do
            {
                Console.Clear();
                Console.WriteLine("Database coding - CRUD");
                Console.WriteLine("Press <ESC> to Exit");
                Console.WriteLine("C) Create");
                Console.WriteLine("R) Read All");
                Console.WriteLine("U) Update");
                Console.WriteLine("D) Delete");
                Console.WriteLine("-------------");
                Console.WriteLine("G) Get by ID");

                info = Console.ReadKey();

                switch (info.Key)
                {
                case ConsoleKey.C:
                    ViewPerson.AddPerson();
                    break;

                case ConsoleKey.R:
                    ViewPerson.PrintToScreen(personRepository.Get());
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.U:
                    Person updatePerson = personRepository.GetPersonById(4);
                    updatePerson.Name = "Patrik";
                    updatePerson.Age  = 34;
                    personRepository.Update(1, updatePerson);
                    break;

                case ConsoleKey.D:
                    personRepository.Delete(5);
                    break;

                case ConsoleKey.G:
                    Console.Write("\nType person <id>, who´s information will show: ");
                    int id = int.Parse(Console.ReadLine());
                    ViewPerson.PrintToScreen(personRepository.GetPersonByIdAndPhones(id));
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;
                }
            } while (info.Key != ConsoleKey.Escape);
        }
Esempio n. 2
0
        public static void UiForConsoleApp()
        {
            ConsoleKeyInfo info;
            var            personRepository = new PersonRepository();

            do
            {
                Console.Clear();
                Console.WriteLine("Database coding - CRUD");
                Console.WriteLine("Press <ESC> to Exit");
                Console.WriteLine("C) Create");
                Console.WriteLine("R) Read All");
                Console.WriteLine("U) Update");
                Console.WriteLine("D) Delete");
                Console.WriteLine("G) Get by ID");
                Console.WriteLine("-------------");

                info = Console.ReadKey();

                switch (info.Key)
                {
                case ConsoleKey.C:
                    ViewPerson.AddPerson();
                    //var person = new Person("Kipe", 22);
                    //personRepository.Create(person);
                    break;

                case ConsoleKey.R:
                    ViewPerson.PrintToScreen(personRepository.Read());
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.U:
                    var updatePerson = personRepository.GetPersonById(10);
                    updatePerson.Name = "Jaska Jokunen";
                    updatePerson.Age  = 45;
                    personRepository.Update(updatePerson, 1);
                    break;

                case ConsoleKey.D:
                    personRepository.Delete(5);
                    break;

                case ConsoleKey.G:
                    Console.Write("\nSyötä henkilön <id>, jonka tiedot näytetään: ");
                    var id = int.Parse(Console.ReadLine());
                    ViewPerson.PrintToScreen(personRepository.GetPersonByIdAndPhones(id));
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.Escape:
                    Console.WriteLine("\nProgram ends after 2 seconds!");
                    for (var i = 0; i < 3; i++)
                    {
                        Console.Write(".");
                        System.Threading.Thread.Sleep(1000);
                    }
                    break;

                case ConsoleKey.A:
                    break;

                case ConsoleKey.Add:
                    break;

                case ConsoleKey.Applications:
                    break;

                case ConsoleKey.Attention:
                    break;

                case ConsoleKey.B:
                    break;

                case ConsoleKey.Backspace:
                    break;

                case ConsoleKey.BrowserBack:
                    break;

                case ConsoleKey.BrowserFavorites:
                    break;

                case ConsoleKey.BrowserForward:
                    break;

                case ConsoleKey.BrowserHome:
                    break;

                case ConsoleKey.BrowserRefresh:
                    break;

                case ConsoleKey.BrowserSearch:
                    break;

                case ConsoleKey.BrowserStop:
                    break;

                case ConsoleKey.Clear:
                    break;

                case ConsoleKey.CrSel:
                    break;

                case ConsoleKey.D0:
                    break;

                case ConsoleKey.D1:
                    break;

                case ConsoleKey.D2:
                    break;

                case ConsoleKey.D3:
                    break;

                case ConsoleKey.D4:
                    break;

                case ConsoleKey.D5:
                    break;

                case ConsoleKey.D6:
                    break;

                case ConsoleKey.D7:
                    break;

                case ConsoleKey.D8:
                    break;

                case ConsoleKey.D9:
                    break;

                case ConsoleKey.Decimal:
                    break;

                case ConsoleKey.Delete:
                    break;

                case ConsoleKey.Divide:
                    break;

                case ConsoleKey.DownArrow:
                    break;

                case ConsoleKey.E:
                    break;

                case ConsoleKey.End:
                    break;

                case ConsoleKey.Enter:
                    break;

                case ConsoleKey.EraseEndOfFile:
                    break;

                case ConsoleKey.Execute:
                    break;

                case ConsoleKey.ExSel:
                    break;

                case ConsoleKey.F:
                    break;

                case ConsoleKey.F1:
                    break;

                case ConsoleKey.F10:
                    break;

                case ConsoleKey.F11:
                    break;

                case ConsoleKey.F12:
                    break;

                case ConsoleKey.F13:
                    break;

                case ConsoleKey.F14:
                    break;

                case ConsoleKey.F15:
                    break;

                case ConsoleKey.F16:
                    break;

                case ConsoleKey.F17:
                    break;

                case ConsoleKey.F18:
                    break;

                case ConsoleKey.F19:
                    break;

                case ConsoleKey.F2:
                    break;

                case ConsoleKey.F20:
                    break;

                case ConsoleKey.F21:
                    break;

                case ConsoleKey.F22:
                    break;

                case ConsoleKey.F23:
                    break;

                case ConsoleKey.F24:
                    break;

                case ConsoleKey.F3:
                    break;

                case ConsoleKey.F4:
                    break;

                case ConsoleKey.F5:
                    break;

                case ConsoleKey.F6:
                    break;

                case ConsoleKey.F7:
                    break;

                case ConsoleKey.F8:
                    break;

                case ConsoleKey.F9:
                    break;

                case ConsoleKey.H:
                    break;

                case ConsoleKey.Help:
                    break;

                case ConsoleKey.Home:
                    break;

                case ConsoleKey.I:
                    break;

                case ConsoleKey.Insert:
                    break;

                case ConsoleKey.J:
                    break;

                case ConsoleKey.K:
                    break;

                case ConsoleKey.L:
                    break;

                case ConsoleKey.LaunchApp1:
                    break;

                case ConsoleKey.LaunchApp2:
                    break;

                case ConsoleKey.LaunchMail:
                    break;

                case ConsoleKey.LaunchMediaSelect:
                    break;

                case ConsoleKey.LeftArrow:
                    break;

                case ConsoleKey.LeftWindows:
                    break;

                case ConsoleKey.M:
                    break;

                case ConsoleKey.MediaNext:
                    break;

                case ConsoleKey.MediaPlay:
                    break;

                case ConsoleKey.MediaPrevious:
                    break;

                case ConsoleKey.MediaStop:
                    break;

                case ConsoleKey.Multiply:
                    break;

                case ConsoleKey.N:
                    break;

                case ConsoleKey.NoName:
                    break;

                case ConsoleKey.NumPad0:
                    break;

                case ConsoleKey.NumPad1:
                    break;

                case ConsoleKey.NumPad2:
                    break;

                case ConsoleKey.NumPad3:
                    break;

                case ConsoleKey.NumPad4:
                    break;

                case ConsoleKey.NumPad5:
                    break;

                case ConsoleKey.NumPad6:
                    break;

                case ConsoleKey.NumPad7:
                    break;

                case ConsoleKey.NumPad8:
                    break;

                case ConsoleKey.NumPad9:
                    break;

                case ConsoleKey.O:
                    break;

                case ConsoleKey.Oem1:
                    break;

                case ConsoleKey.Oem102:
                    break;

                case ConsoleKey.Oem2:
                    break;

                case ConsoleKey.Oem3:
                    break;

                case ConsoleKey.Oem4:
                    break;

                case ConsoleKey.Oem5:
                    break;

                case ConsoleKey.Oem6:
                    break;

                case ConsoleKey.Oem7:
                    break;

                case ConsoleKey.Oem8:
                    break;

                case ConsoleKey.OemClear:
                    break;

                case ConsoleKey.OemComma:
                    break;

                case ConsoleKey.OemMinus:
                    break;

                case ConsoleKey.OemPeriod:
                    break;

                case ConsoleKey.OemPlus:
                    break;

                case ConsoleKey.P:
                    break;

                case ConsoleKey.Pa1:
                    break;

                case ConsoleKey.Packet:
                    break;

                case ConsoleKey.PageDown:
                    break;

                case ConsoleKey.PageUp:
                    break;

                case ConsoleKey.Pause:
                    break;

                case ConsoleKey.Play:
                    break;

                case ConsoleKey.Print:
                    break;

                case ConsoleKey.PrintScreen:
                    break;

                case ConsoleKey.Process:
                    break;

                case ConsoleKey.Q:
                    break;

                case ConsoleKey.RightArrow:
                    break;

                case ConsoleKey.RightWindows:
                    break;

                case ConsoleKey.S:
                    break;

                case ConsoleKey.Select:
                    break;

                case ConsoleKey.Separator:
                    break;

                case ConsoleKey.Sleep:
                    break;

                case ConsoleKey.Spacebar:
                    break;

                case ConsoleKey.Subtract:
                    break;

                case ConsoleKey.T:
                    break;

                case ConsoleKey.Tab:
                    break;

                case ConsoleKey.UpArrow:
                    break;

                case ConsoleKey.V:
                    break;

                case ConsoleKey.VolumeDown:
                    break;

                case ConsoleKey.VolumeMute:
                    break;

                case ConsoleKey.VolumeUp:
                    break;

                case ConsoleKey.W:
                    break;

                case ConsoleKey.X:
                    break;

                case ConsoleKey.Y:
                    break;

                case ConsoleKey.Z:
                    break;

                case ConsoleKey.Zoom:
                    break;

                default:
                    Console.WriteLine("\nWrong KEY - try again!");
                    System.Threading.Thread.Sleep(1000);
                    break;
                }
            } while (info.Key != ConsoleKey.Escape);
        }
Esempio n. 3
0
        public static void UIForConsoleApp()
        {
            ConsoleKeyInfo   info;
            PersonRepository personRepository = new PersonRepository();

            do
            {
                Console.Clear();
                Console.WriteLine("Database coding - CRUD");
                Console.WriteLine("Press <ESC> to Exit");
                Console.WriteLine("C) Create");
                Console.WriteLine("R) Read All");
                Console.WriteLine("U) Update");
                Console.WriteLine("D) Delete");
                Console.WriteLine("-------------");
                Console.WriteLine("G) Get by ID");

                info = Console.ReadKey();

                switch (info.Key)
                {
                case ConsoleKey.C:
                    ViewPerson.AddPerson();
                    //var person = new Person("Jorska", 25);
                    //personRepository.Create(person);
                    break;

                case ConsoleKey.R:
                    ViewPerson.PrintToScreen(personRepository.Get());
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.U:
                    Person updatePerson = personRepository.GetPersonById(10);
                    updatePerson.Name = "James Bond";
                    updatePerson.Age  = 55;
                    personRepository.Update(1, updatePerson);
                    break;

                case ConsoleKey.D:
                    personRepository.Delete(5);
                    break;

                case ConsoleKey.G:
                    Console.Write("\nSyötä henkilön <id>, jonka tiedot näytetään: ");
                    int id = int.Parse(Console.ReadLine());
                    ViewPerson.PrintToScreen(personRepository.GetPersonByIdAndPhones(id));
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.Escape:
                    Console.WriteLine("\nProgram end after 3 sec!");
                    for (int i = 0; i < 3; i++)
                    {
                        Console.Write(".");
                        System.Threading.Thread.Sleep(1000);
                    }
                    break;

                default:
                    Console.WriteLine("\nWrong KEY - try again!");
                    System.Threading.Thread.Sleep(2000);
                    break;
                }
            } while (info.Key != ConsoleKey.Escape);
        }
Esempio n. 4
0
        public static void UIForConsoleApp()
        {
            ConsoleKeyInfo   info;
            PersonRepository personRepository = new PersonRepository();

            do
            {
                Console.Clear();
                Console.WriteLine("Database coding - CRUD");
                Console.WriteLine("Press <ESC> to Exit");
                Console.WriteLine("C) Create");
                Console.WriteLine("R) Read All");
                Console.WriteLine("U) Update");
                Console.WriteLine("D) Delete");
                Console.WriteLine("-------------");
                Console.WriteLine("G) Get by ID");
                Console.WriteLine("A) Update Phone");

                info = Console.ReadKey();

                switch (info.Key)
                {
                case ConsoleKey.C:
                    ViewPerson.AddPerson();
                    //var person = new Person("Masa", 25);
                    //personRepository.Create(person);
                    break;

                case ConsoleKey.R:
                    ViewPerson.PrintToScreen(personRepository.Get());
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.U:
                    Person updatePerson = personRepository.GetPersonById(10);
                    updatePerson.Name = "Jouni";
                    updatePerson.Age  = 50;
                    personRepository.Update(1, updatePerson);
                    break;

                case ConsoleKey.D:
                    personRepository.Delete(5);
                    break;

                case ConsoleKey.G:
                    Console.Write("\nSyötä henkilön <id>, jonka tiedot näytetään: ");
                    int id = int.Parse(Console.ReadLine());
                    ViewPerson.PrintToScreen(personRepository.GetPersonByIdAndPhones(id));
                    Console.WriteLine("Press <Enter> to continue ...");
                    Console.ReadLine();
                    break;

                case ConsoleKey.A:
                    Console.Write("\nSyötä henkilön <id>, jonka tiedot näytetään: ");
                    id = int.Parse(Console.ReadLine());
                    Person updatePersonAndPhone = personRepository.GetPersonByIdAndPhones(id);
                    ViewPerson.PrintToScreen(personRepository.GetPersonByIdAndPhones(id));
                    Console.Write("Valitse <Id>, jonka haluat muuttaa: ");
                    int phnId = int.Parse(Console.ReadLine());
                    Console.Write("Syötä uusi numero: ");
                    string newNumber = Console.ReadLine();
                    foreach (var phn in updatePersonAndPhone.Phone)
                    {
                        if (phn.Id == phnId)
                        {
                            phn.Number = newNumber;
                        }
                    }
                    personRepository.Update(10, updatePersonAndPhone);
                    break;

                case ConsoleKey.Escape:
                    Console.WriteLine("\nProgram end after 3 sec!");
                    for (int i = 0; i < 3; i++)
                    {
                        Console.Write(".");
                        System.Threading.Thread.Sleep(1000);
                    }
                    break;

                default:
                    Console.WriteLine("\nWrong KEY - try again!");
                    System.Threading.Thread.Sleep(2000);
                    break;
                }
            } while (info.Key != ConsoleKey.Escape);
        }