Beispiel #1
0
        private void HandleEventAddNewBoat(Model.Member member, View.Console view, Model.MemberRegister register)
        {
            view.ShowInputInfo(View.Console.MenuEvent.AddBoat, member);
            Model.Boat boat = new Model.Boat();
            boat.ID = register.GetNextBoatIdFor(member);

            try
            {
                boat.Model = (Model.Boat.BoatModel)view.InputBoatModel();
            }
            catch (ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidBoatModel, null);
                view.Wait();
                return;
            }

            try
            {
                boat.Length = view.InputBoatLenght();
            }
            catch (ArgumentException)
            {
                view.ShowErrorMessage(View.Console.Error.InvalidBoatLenght, null);
                view.Wait();
                return;
            }

            member.AddBoat(boat);
            register.Save();
        }
Beispiel #2
0
        private void HandleEventShowEditBoatMenu(Model.Member member, Model.Boat boat,
                                                 View.Console view, Model.MemberRegister register)
        {
            while (true)
            {
                view.ShowMenu(View.Console.MenuEvent.EditBoatMenu, member);
                switch (view.GetMenuSelection())
                {
                case View.Console.MenuEvent.EditBoatModel:
                    view.ShowInputInfo(View.Console.MenuEvent.EditBoatModel, member);
                    try
                    {
                        boat.Model = (Model.Boat.BoatModel)view.InputBoatModel();
                        register.Save();
                    }
                    catch (ArgumentException)
                    {
                        view.ShowErrorMessage(View.Console.Error.InvalidBoatModel, null);
                        view.Wait();
                        return;
                    }
                    break;

                case View.Console.MenuEvent.EditBoatLength:
                    view.ShowInputInfo(View.Console.MenuEvent.EditBoatLength, member);
                    try
                    {
                        boat.Length = view.InputBoatLenght();
                        register.Save();
                        break;
                    }
                    catch (ArgumentException)
                    {
                        view.ShowErrorMessage(View.Console.Error.InvalidBoatLenght, null);
                        view.Wait();
                        break;
                    }

                case View.Console.MenuEvent.Back:
                    // exit menu
                    return;
                }
            }
        }