public Floor(NpgsqlConnection connection, Garage garage) { this.connection = connection; this.garage = garage; this.Spot = garage.SpotPerFloor; }
public Search(NpgsqlConnection connection, string numberplate, Garage garage) { this.connection = connection; this.numberplate = numberplate; this.garage = garage; }
public static List <Floor> GetAllFloorsWithSpots(NpgsqlConnection connection, Garage garage) { List <Floor> allFloors = new List <Floor>(); NpgsqlCommand command = new NpgsqlCommand(); command.Connection = connection; command.CommandText = $"Select Distinct floors, floor_id from Parkgarage.floors where garage_id = :id order by floors;"; command.Parameters.AddWithValue("id", garage.GarageId.Value); NpgsqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { allFloors.Add(new Floor(connection, garage) { FloorNumber = reader.IsDBNull(0) ? 0 : (long?)reader.GetInt64(0), FloorId = reader.IsDBNull(1) ? null : (long?)reader.GetInt64(1) } ); } reader.Close(); } foreach (Floor floor in allFloors) { floor.Spots = _360Consulting.Parkgarage.Data.Spot.GetAllSpotsPerFloor(connection, floor); } return(allFloors); }