Пример #1
0
        //Visar antingen en eller alla medlemmar beroende på om viewAll är true eller false
        private static void ViewMember(List<Member> members, bool viewAll = false)
        {
            MemberView memberView = new MemberView();

            if (viewAll == false)
            {
                do
                {
                    string header = "       Välj medlem att visa        ";
                    Member memberSelection = GetMember(header, members);

                    if (memberSelection == null)
                    {
                        break;
                    }
                    else
                    {
                        Console.Clear();

                        memberView.Render(memberSelection);

                        ContinueOnKeyPressed();
                    }
                } while (true);
            }
            else
            {
                if (members == null || members.Count == 0)
                {
                    Console.BackgroundColor = ConsoleColor.DarkYellow;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("\n Det finns inga medlemmar i registret");
                    Console.ResetColor();
                    ContinueOnKeyPressed();
                }
                else
                {
                    Console.Clear();
                    memberView.Render(members);
                    ContinueOnKeyPressed();
                }
            }
        }
Пример #2
0
        // Method to view a member.
        private static void ViewMember(List<Member> members, bool viewAll = false)
        {
            string header;
            MemberView mView = new MemberView();

            // Check if there's any members otherwise display a warning message.
            if (members != null && members.Any())
            {
                if (!viewAll)
                {
                    Console.Clear();
                    mView.RenderHeader("       Välj medlem att visa       ");

                    // Get the member we want using the GetMember method.
                    Member m = GetMember("Välj medlem att visa", members);

                    // If m is null just break out of the method.
                    if (m == null)
                    {
                        return;
                    }

                    // Display a header from the RenderHeader method.
                    Console.Clear();
                    header = String.Format("      Visar medlem, {0} {1}      ", m.FirstName, m.LastName);
                    mView.RenderHeader(header);

                    // And render the user.
                    mView.Render(m);
                }
                else
                {
                    // Renders all the members.
                    Console.Clear();
                    mView.Render(members);
                }
            }
            else
            {
                // Display a header from the RenderHeader method.
                Console.Clear();
                mView.RenderHeader(" Det finns inga medlemmar att visa", bgcolor: ConsoleColor.Yellow, fgcolor: ConsoleColor.Black);
            }
        }