private static void FindReadersByTicket(IReaderService rs, IRecordService recsc)
        {
            Console.Clear();
            Console.WriteLine("You have chosen finding readers by ticket");
            Console.Write("Input ticket number: ");
            var ticketIn = Console.ReadLine();

            if (int.TryParse(ticketIn, out int num))
            {
                var readers = rs.FindReaderByTicket(num);

                if (readers == null || readers.Count() == 0)
                {
                    Console.WriteLine("nothing was found");
                }
                else if (readers.Count() > 1)
                {
                    Console.WriteLine("It seems that there is more than one reader with such ticket number");
                }
                else
                {
                    var res = readers.FirstOrDefault();

                    Console.WriteLine("\nResult\n");
                    Console.WriteLine($"{"Full name",-25} | {"Ticket number",-12} | {"Phone number",-20}");
                    Console.WriteLine($"{res.Fullname,-25} | {res.TicketNumber,-12} | {res.Phone,-20}");

                    Console.WriteLine("To see activity choose:\n" +
                                      "r - to see returned books\n" +
                                      "b - to see currently borrowed books\n" +
                                      "any key to return to menu");

                    var inp = Console.ReadLine();

                    switch (inp.Trim())
                    {
                    case "r":
                    case "R":
                        GetReturnedBooks(rs, recsc, res);
                        break;

                    case "b":
                    case "B":
                        GetBorrowedBooks(rs, recsc, res);
                        break;

                    default:
                        return;
                    }
                }
            }
            else
            {
                Console.WriteLine("Bad input");
            }

            Console.Write("Press any key to return to menu");
            Console.ReadLine();
        }
Esempio n. 2
0
        public ObservableCollection <ReaderModel> FindReaderByTicket(int number)
        {
            var res = _service.FindReaderByTicket(number);

            return(new ObservableCollection <ReaderModel>(res.Select(r => _mapper.Map(r))));
        }