Exemple #1
0
        /// <summary>
        /// Create a new instance of a Parcel.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pid"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Parcel CreateParcel(this PimsContext context, int pid, double lat = 0, double lng = 0, Entity.Agency agency = null)
        {
            agency ??= context.Agencies.FirstOrDefault() ?? EntityHelper.CreateAgency(pid);
            var address        = context.CreateAddress(pid, "1234 Street", null, "V9C9C9");
            var classification = context.PropertyClassifications.FirstOrDefault(s => s.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification");

            var parcel = new Entity.Parcel(pid, lat, lng)
            {
                Id               = pid,
                Agency           = agency,
                AgencyId         = agency.Id,
                Address          = address,
                AddressId        = address.Id,
                Classification   = classification,
                ClassificationId = classification.Id,
                Description      = $"description-{pid}",
                CreatedById      = Guid.NewGuid(),
                CreatedOn        = DateTime.UtcNow,
                UpdatedById      = Guid.NewGuid(),
                UpdatedOn        = DateTime.UtcNow,
                RowVersion       = new byte[] { 12, 13, 14 }
            };

            context.Parcels.Add(parcel);
            return(parcel);
        }
Exemple #2
0
        /// <summary>
        /// Create a new instance of an Property.
        /// Adds the property to the specified 'context'.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pid"></param>
        /// <param name="type"></param>
        /// <param name="classification"></param>
        /// <param name="address"></param>
        /// <param name="tenure"></param>
        /// <param name="areaUnit"></param>
        /// <param name="dataSource"></param>
        /// <returns></returns>
        public static Entity.PimsProperty CreateProperty(this PimsContext context, int pid, int?pin = null, Entity.PimsPropertyType type = null, Entity.PimsPropertyClassificationType classification = null, Entity.PimsAddress address = null, Entity.PimsPropertyTenureType tenure = null, Entity.PimsAreaUnitType areaUnit = null, Entity.PimsDataSourceType dataSource = null)
        {
            type ??= context.PimsPropertyTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property type.");
            classification ??= context.PimsPropertyClassificationTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property classification type.");
            address ??= context.CreateAddress(pid, "12342 Test Street");
            tenure ??= context.PimsPropertyTenureTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property tenure type.");
            areaUnit ??= context.PimsAreaUnitTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property area unit type.");
            dataSource ??= context.PimsDataSourceTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property data source type.");
            var lease    = context.PimsLeases.FirstOrDefault() ?? EntityHelper.CreateLease(pid);
            var property = EntityHelper.CreateProperty(pid, pin, type, classification, address, tenure, areaUnit, dataSource);

            context.PimsProperties.Add(property);
            return(property);
        }