/// <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(); } } }
public async Task Add(BoatRegister req) { context.Boat.Add(new Boat { BoatId = req.Id, HourlyRate = req.HourlyRate, Image = req.Image, Status = BoatStatus.ReadyToRent, Name = req.Name }); await context.SaveChangesAsync(); }
/// <summary> /// Removes boat from a member /// </summary> public void RemoveBoat() { string pId = _boatView.InputSsn(); if (!IsCorrectInputOfSsn(pId)) { RemoveBoat(); } BoatRegister boatRegister = MemberRegister.GetMemberBySsn(pId).BoatRegister; 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.PrintNotADoubleAboveZero(); RemoveBoat(); } else { int id = ConvertToInt(idString); if (boatRegister.IsBoat(id)) { boatRegister.DeleteById(id); _boatView.PrintActionSuccess(); } else { _boatView.PrintActionFail(); } } }
public async Task <ActionResult <BoatRegister> > Post(BoatRegister req) { await register.Add(req); return(CreatedAtAction("Created", req)); }
public List <Boat> RegisterBoat(float length, string boatType) { model.Boat newBoat = new model.Boat(length, boatType); BoatRegister.Add(newBoat); return(BoatRegister); }