Esempio n. 1
0
        public static Member SelectMember(string option)
        {
            List <Member> members = MemberRepository.GetMembers();

            CommonClasses.StandardMessages.ListAllItems("members");
            CommonClasses.StandardMessages.ChooseMemberOptions(option);

            int i = 1;

            foreach (Member member in members)
            {
                Console.WriteLine($"{i} {member.Name} {member.Age}");
                i++;
            }

            StandardMessages.SelectMemberToDelete();
            string input = Console.ReadLine();

            int.TryParse(input, out int indexSelected);

            bool isValid = Validations.SelectedIndex(indexSelected, i, members.Count);

            if (isValid)
            {
                return(members[indexSelected - 1]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static void CreateMember()
        {
            StandardMessages.CreateMessage("a Member");
            Member member = MemberDataCapture.Member();

            MemberRepository.SaveMemberToDB(member);
            StandardMessages.WasCreatedMessage("member");
        }
Esempio n. 3
0
        public static void CreateMovie()
        {
            StandardMessages.CreateMessage("a Movie");
            Movie movie = ItemDataCapture.Movie();

            MovieRepository.SaveMovieToDB(movie);
            StandardMessages.WasCreatedMessage("book");
        }
Esempio n. 4
0
        public static void CreateBook()
        {
            StandardMessages.CreateMessage("a Book");
            Book book = ItemDataCapture.Book();

            BookRepository.SaveBookToDB(book);
            StandardMessages.WasCreatedMessage("book");
        }
Esempio n. 5
0
        /// <summary>
        /// the user gets to select a movie by index and delete it
        /// </summary>
        public static void DeleteMovie()
        {
            Movie movie = CommonClasses.SelectMovieById.SelectMovie("delete");

            if (movie != null)
            {
                MovieRepository.DeleteMovie(movie.Id);
                StandardMessages.DeletedMessage("movie");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// the user gets to select a book by index and delete it
        /// </summary>
        public static void DeleteBook()
        {
            Book book = CommonClasses.SelectBookById.SelectBook("delete");

            if (book != null)
            {
                BookRepository.DeleteBook(book.Id);
                StandardMessages.DeletedMessage("book");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// the user gets to select a member by index and delete it
        /// </summary>
        public static void DeleteMember()
        {
            Member member = SelectMember("delete");

            if (member != null)
            {
                MemberRepository.DeleteMember(member.Id);
                StandardMessages.DeletedMessage("member");
            }
        }
Esempio n. 8
0
        public static void UpdateMember()
        {
            Member memberToUpdate = SelectMemberById.SelectMember("update");

            if (memberToUpdate != null)
            {
                Member updatedMember = MemberDataCapture.Member();
                MemberRepository.UpdateMember(memberToUpdate.Id, updatedMember.Name, updatedMember.Age);
                StandardMessages.UpdatedMessage("member");
            }
        }
Esempio n. 9
0
        public static void UpdateMovie()
        {
            Movie movieToUpdate = SelectMovieById.SelectMovie("update");

            if (movieToUpdate != null)
            {
                Movie updatedMovie = ItemDataCapture.Movie();
                MovieRepository.UpdateMovie(movieToUpdate.Id, updatedMovie);
                StandardMessages.UpdatedMessage("movie");
            }
        }
Esempio n. 10
0
        public static void UpdateBook()
        {
            Book bookToUpdate = SelectBookById.SelectBook("update");

            if (bookToUpdate != null)
            {
                Book updatedBook = ItemDataCapture.Book();
                BookRepository.UpdateBook(bookToUpdate.Id, updatedBook);
                StandardMessages.UpdatedMessage("book");
            }
        }
Esempio n. 11
0
 private void PrintMainMenu()
 {
     StandardMessages.Header();
     Console.WriteLine("[1] Create New Item");
     Console.WriteLine("[2] Create New Member");
     Console.WriteLine("[3] Delete from Database");
     Console.WriteLine("[4] Update in Database");
     Console.WriteLine("[5] Borrow a Book");
     Console.WriteLine("[6] Borrow a Movie");
     Console.WriteLine("[7] Return Item");
     Console.WriteLine("[8] All lists in Database");
     //Console.WriteLine("[9] ");
     Console.WriteLine("[0] Exit");
 }
Esempio n. 12
0
        public static void CreateSwitch()
        {
            StandardMessages.SelectItem("create");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                MenuOptions.CreateBook();
                break;

            case "2":
                MenuOptions.CreateMovie();
                break;

            default:
                CommonClasses.StandardMessages.InvalidOption();
                break;
            }
        }
Esempio n. 13
0
        public static void ReturnItem(Member member)
        {
            StandardMessages.SelectItem("return");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                CommonClasses.ReturnItem.UpdateBookLoan(member);
                break;

            case "2":
                CommonClasses.ReturnItem.UpdateMovieLoan(member);
                break;

            default:
                CommonClasses.StandardMessages.InvalidOption();
                break;
            }
        }
Esempio n. 14
0
        public static void PrintAnyList()
        {
            StandardMessages.SelectList("List");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                PrintListsFromDB.PrintBooksList();
                break;

            case "2":
                PrintListsFromDB.PrintMoviesList();
                break;

            case "3":
                PrintMembersFromDB.PrintMembersList();
                break;

            default:
                CommonClasses.StandardMessages.InvalidOption();
                break;
            }
        }
Esempio n. 15
0
        public static void DeleteSwitch()
        {
            StandardMessages.SelectList("Delete");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                DeleteItem.DeleteBook();
                break;

            case "2":
                DeleteItem.DeleteMovie();
                break;

            case "3":
                SelectMemberById.DeleteMember();
                break;

            default:
                CommonClasses.StandardMessages.InvalidOption();
                break;
            }
        }