/// <summary> /// Adds boat to a member /// </summary> public void AddBoat() { BoatTypeMenu boatTypeMenu = new BoatTypeMenu(); string pId = _boatView.InputSsn(); if (!IsCorrectInputOfSsn(pId)) { AddBoat(); } else { BoatRegister boatRegister = MemberRegister.GetMemberBySsn(pId).BoatRegister; boatTypeMenu.DisplayMenu(); BoatType boatType = boatTypeMenu.GetInput(); string lengthString = _boatView.InputBoatLength(); if (ConvertToDouble(lengthString) == 0) { _boatViewWrongInputMessages.PrintNotADoubleAboveZero(); AddBoat(); } else { boatRegister.AddBoat(boatType, ConvertToDouble(lengthString)); _boatView.PrintActionSuccess(); } } }
/// <summary> /// Updates boat on a member /// </summary> public void UpdateBoat() { BoatTypeMenu boatTypeMenu = new BoatTypeMenu(); string pId = _boatView.InputSsn(); if (!IsCorrectInputOfSsn(pId)) { UpdateBoat(); } BoatRegister boatRegister; if (MemberRegister.MemberExist(pId)) { boatRegister = MemberRegister.GetMemberBySsn(pId).BoatRegister; } else { _boatViewWrongInputMessages.PrintSsnNotExisting(); return; } if (boatRegister.Boats.Count == 0) { _boatViewWrongInputMessages.PrintNoBoatsFound(); return; } else { int count = 0; foreach (Boat boat in boatRegister.Boats) { count += 1; _boatView.PrintBoatInformation(count, boat.Type, boat.Length, boat.BoatId); } _boatView.PrintEndOfInformation(); } string idString = _boatView.InputBoatId(); if (ConvertToInt(idString) == 0) { _boatViewWrongInputMessages.PrintNotAnIntAboveZero(); UpdateBoat(); } else { int id = ConvertToInt(idString); if (boatRegister.IsBoat(id)) { boatTypeMenu.DisplayMenu(); BoatType boatType = boatTypeMenu.GetInput(); string lengthString = _boatView.InputBoatLength(); if (ConvertToDouble(lengthString) == 0) { _boatViewWrongInputMessages.PrintNotADoubleAboveZero(); UpdateBoat(); } boatRegister.UpdateBoat(id, boatType, ConvertToDouble(lengthString)); _boatView.PrintActionSuccess(); } else { _boatView.PrintActionFail(); } } }