コード例 #1
0
        private void RegisterBorrowingOpening()
        {
            DisplayerHeader("REGISTER BORROWING");

            Console.WriteLine(" - Enter id of the Borrowed magazine.");
            string magazineIdTxt = Console.ReadLine();

            if (!int.TryParse(magazineIdTxt, out int magazineId))
            {
                DisplayErrorText("Attribute id of the magazine must a valid integer.");
                return;
            }

            Console.WriteLine(" - Enter id of the friend that Borrowed the magazine");
            string friendIdTxt = Console.ReadLine();

            if (!int.TryParse(friendIdTxt, out int friendId))
            {
                DisplayErrorText("Attribute id of the storage box must a valid integer.");
                return;
            }

            Friend   friend   = (Friend)controllerFriend.SelectEntityById(friendId);
            Magazine magazine = (Magazine)controllerMagazine.SelectEntityById(magazineId);

            Borrowing borrowing = new Borrowing(0, magazine, friend, DateTime.Now);
            string    response  = mainController.CreateEntity(borrowing);

            if (response != "OP_SUCCESS")
            {
                DisplayErrorText(response);
            }
            else
            {
                DisplaySuccessText("Register Operation Sucessful");
                Console.ReadLine();
                return;
            }
        }