Ejemplo n.º 1
0
 /// <summary>
 /// Get the first parcel this building is located on.
 /// </summary>
 /// <param name="building"></param>
 /// <returns></returns>
 public static int?GetParcelId(this Entity.Building building)
 {
     return(building.Parcels.FirstOrDefault()?.ParcelId);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Make a query to determine if the building names are unique.
        /// - No two buildings should have the same name on a parcel.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="parcel"></param>
        /// <param name="building"></param>
        /// <exception type="DbUpdateException">The name within a parcel should be unique.</exception>
        public static void ThrowIfNotUnique(this PimsContext context, Entity.Parcel parcel, Entity.Building building)
        {
            if (parcel == null || String.IsNullOrEmpty(building.Name))
            {
                return;
            }
            var parcelBuildings = context.Parcels.Where(p => p.Id == parcel.Id).SelectMany(p => p.Buildings).Where(b => b.BuildingId != building.Id).Select(b => b.Building.Name).Distinct().ToArray();
            var alreadyExists   = parcelBuildings.Contains(building.Name);

            if (alreadyExists)
            {
                throw new DbUpdateException("A building name must be unique on the parcel.");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the building preduminate use name.
 /// </summary>
 /// <param name="building"></param>
 /// <returns></returns>
 public static string GetPredominateUse(this Entity.Building building)
 {
     return(building.BuildingPredominateUse?.Name);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Get the building occupant type name.
 /// </summary>
 /// <param name="building"></param>
 /// <returns></returns>
 public static string GetOccupantType(this Entity.Building building)
 {
     return(building.BuildingOccupantType?.Name);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Get the building construction type name.
 /// </summary>
 /// <param name="building"></param>
 /// <returns></returns>
 public static string GetConstructionType(this Entity.Building building)
 {
     return(building.BuildingConstructionType?.Name);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Get a building zoning potential
 /// </summary>
 /// <param name="building"></param>
 /// <returns></returns>
 public static string[] GetZoningPotential(this Entity.Building building)
 {
     return(building.Parcels.Select(p => p.Parcel.ZoningPotential).Where(s => !String.IsNullOrWhiteSpace(s)).ToArray());
 }