Exemplo n.º 1
0
 /// <summary>
 /// Deletes a new boat and calls the database class to remove it from the database.
 /// </summary>
 /// <param name="id">The boat id.</param>
 public override void DeleteById(int id)
 {
     if (Database.BoatIdExist(id, _ownerPersonalId).Result)
     {
         Database.RemoveBoatById(id, _ownerPersonalId).Wait();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Method that checks if a boat exist based on the inputted id.
 /// </summary>
 /// <return>
 /// True or false
 ///</returns>
 /// <param name="id">A Boat id to be checked.</param>
 public bool IsBoat(int id)
 {
     if (Database.BoatIdExist(id, _ownerPersonalId).Result)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates a boat and calls the database class to add changes to the database.
 /// </summary>
 /// <param name="boatType">A BoatType enum.</param>
 /// <param name="length">The boat length.</param>
 public void UpdateBoat(int id, BoatType boatType, double length)
 {
     if (Database.BoatIdExist(id, _ownerPersonalId).Result)
     {
         Boat newBoat = new Boat()
         {
             Type   = boatType,
             Length = length,
             BoatId = id
         };
         Database.AddBoat(newBoat, _ownerPersonalId).Wait();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Method that generates a new unique id.
        /// </summary>
        /// <return>
        /// The unique ID
        ///</returns>
        public override int GenerateId()
        {
            Random a = new Random();

            int newBoatId;

            newBoatId = a.Next(0, 100000000);

            while (Database.BoatIdExist(newBoatId, _ownerPersonalId).Result)
            {
                newBoatId = a.Next(0, 100000000);
            }

            return(newBoatId);
        }