Beispiel #1
0
        public void HandleEventShowManageBoatsMenu(Model.Member member, View.Console view, Model.MemberRegister register)
        {
            while (true)
            {
                view.ShowMenu(View.Console.MenuEvent.ManageBoatsMenu, member);
                int boatId;

                switch (view.GetMenuSelection())
                {
                    case View.Console.MenuEvent.AddBoat:
                        HandleEventAddNewBoat(member, view, register);
                        break;
                    case View.Console.MenuEvent.EditBoatMenu:
                        if (member.GetBoatCount() == 1)
                        {
                            boatId = member.GetBoats().First().ID;
                        }
                        else
                        {
                            view.ShowInputInfo(View.Console.MenuEvent.EditBoatMenu, member);
                            boatId = view.InputBoatID();
                        }

                        try
                        {
                            Model.Boat b = member.GetBoat(boatId);
                            HandleEventShowEditBoatMenu(member, b, view, register);
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoBoatWithId, boatId.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.DeleteBoat:
                        if (member.GetBoatCount() == 1)
                        {
                            boatId = member.GetBoats().First().ID;
                        }
                        else
                        {
                            view.ShowInputInfo(View.Console.MenuEvent.DeleteBoat, member);
                            boatId = view.InputBoatID();
                        }

                        try
                        {
                            member.DeleteBoat(boatId);
                            break;
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoBoatWithId, boatId.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.Back:
                        // exit menu
                        return;
                }
            }
        }