public static ParkingLot CreateParkingLot(ParkingLotBuilder builder) { if (string.IsNullOrWhiteSpace(builder.Name) || builder.Address == null || builder.Capacity <= 0 || builder.ContactPerson == null || builder.PricePerHour < 0) { return(null); } return(new ParkingLot( builder.Name, builder.DivisionID, builder.Buildingtype, builder.Capacity, builder.ContactPerson, builder.Address, builder.PricePerHour)); }
public static ParkingLot CreateParkingLot(ParkingLotBuilder builder) { //Throw validation exception, not return null, make it explicit that the consumer has made an error if (string.IsNullOrWhiteSpace(builder.Name) || builder.Address == null || builder.Capacity <= 0 || builder.ContactPerson == null || builder.PricePerHour < 0) { return(null); } return(new ParkingLot( builder.Name, builder.DivisionID, builder.Buildingtype, builder.Capacity, builder.ContactPerson, builder.Address, builder.PricePerHour)); }