コード例 #1
0
        /// <summary>
        /// Create a new instance of a Parcel.
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Parcel CreateParcel(int pid, double lat, double lng, Entity.Agency agency, Entity.Address address = null)
        {
            agency ??= EntityHelper.CreateAgency(pid);
            if (address == null)
            {
                address = EntityHelper.CreateAddress(pid, "1234 Street", null, "V9C9C9");
            }
            var classification = EntityHelper.CreatePropertyClassification("classification");

            return(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 }
            });
        }
コード例 #2
0
        /// <summary>
        /// Create a new instance of a Property.
        /// </summary>
        /// <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(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, Entity.PimsLease lease = null)
        {
            type ??= EntityHelper.CreatePropertyType("Land");
            classification ??= EntityHelper.CreatePropertyClassificationType("Class");
            address ??= EntityHelper.CreateAddress(pid);
            tenure ??= EntityHelper.CreatePropertyTenureType("Tenure");

            areaUnit ??= EntityHelper.CreatePropertyAreaUnitType("Sqft");
            dataSource ??= EntityHelper.CreateDataSourceType("LIS");
            var property = new Entity.PimsProperty(pid, type, classification, address, new Entity.PimsPropPropTenureType {
                PropertyTenureTypeCodeNavigation = tenure
            }, areaUnit, dataSource, DateTime.UtcNow)
            {
                PropertyId = pid,
                Pin        = pin,
                ConcurrencyControlNumber = 1,
                Location = new NetTopologySuite.Geometries.Point(0, 0)
            };

            if (lease != null)
            {
                lease.PimsPropertyLeases.Add(new Entity.PimsPropertyLease()
                {
                    Property = property, Lease = lease
                });
            }
            return(property);
        }
コード例 #3
0
ファイル: BuildingHelper.cs プロジェクト: sookeke/PIMS
        /// <summary>
        /// Creates a new instance of a Building.
        /// </summary>
        /// <param name="parcel"></param>
        /// <param name="id"></param>
        /// <param name="projectNumber"></param>
        /// <param name="name"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Building CreateBuilding(Entity.Parcel parcel, int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null)
        {
            projectNumber ??= $"p{id}";
            agency ??= parcel.Agency;
            var address          = EntityHelper.CreateAddress(++parcel.AddressId, parcel.Address.Address1, parcel.Address.Address2, parcel.Address.AdministrativeArea, parcel.Address.Province, parcel.Address.Postal);
            var predominateUse   = EntityHelper.CreateBuildingPredominateUse("use");
            var constructionType = EntityHelper.CreateBuildingConstructionType("type");
            var occupantType     = EntityHelper.CreateBuildingOccupantType("occupant");
            var classification   = EntityHelper.CreatePropertyClassification("classification");

            return(new Entity.Building(parcel, lat, lng)
            {
                Id = id,
                ProjectNumber = projectNumber,
                AgencyId = agency.Id,
                Agency = agency,
                Name = name,
                AddressId = address.Id,
                Address = address,
                Classification = classification,
                ClassificationId = classification.Id,
                Description = $"description-{id}",
                BuildingPredominateUse = predominateUse,
                BuildingPredominateUseId = predominateUse.Id,
                BuildingConstructionType = constructionType,
                BuildingConstructionTypeId = constructionType.Id,
                BuildingOccupantType = occupantType,
                BuildingOccupantTypeId = occupantType.Id,
                CreatedById = Guid.NewGuid(),
                CreatedOn = DateTime.UtcNow,
                UpdatedById = Guid.NewGuid(),
                UpdatedOn = DateTime.UtcNow,
                RowVersion = new byte[] { 12, 13, 14 }
            });
        }
コード例 #4
0
 /// <summary>
 /// Create a new instance of a Parcel.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public static Entity.PimsOrganization CreateOrganization(long id, string name, Entity.PimsOrganizationType type = null, Entity.PimsOrgIdentifierType identifierType = null, Entity.PimsAddress address = null)
 {
     type ??= EntityHelper.CreateOrganizationType("Type 1");
     identifierType ??= EntityHelper.CreateOrganizationIdentifierType("Identifier 1");
     address ??= EntityHelper.CreateAddress(id);
     return(new Entity.PimsOrganization(name, type, identifierType, address)
     {
         Id = id,
         ConcurrencyControlNumber = 1
     });
 }
コード例 #5
0
        /// <summary>
        /// Create a new instance of a Parcel and add it to the database context.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="identifierType"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static Entity.PimsOrganization CreateOrganization(this PimsContext context, long id, string name, Entity.PimsOrganizationType type = null, Entity.PimsOrgIdentifierType identifierType = null, Entity.PimsAddress address = null)
        {
            type ??= context.PimsOrganizationTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find an organization type.");
            identifierType ??= context.PimsOrgIdentifierTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find an organization identifier type.");
            address ??= EntityHelper.CreateAddress(id);
            var organization = new Entity.PimsOrganization(name, type, identifierType, address)
            {
                Id = id,
                ConcurrencyControlNumber = 1
            };

            return(organization);
        }
コード例 #6
0
ファイル: PersonHelper.cs プロジェクト: asanchezr/PSP
 /// <summary>
 /// Create a new instance of an Person.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="surname"></param>
 /// <param name="firstName"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public static Entity.PimsPerson CreatePerson(long id, string surname, string firstName, Entity.PimsAddress address = null)
 {
     return(new Entity.PimsPerson(surname, firstName, address ?? EntityHelper.CreateAddress(id))
     {
         PersonId = id,
         AppCreateUserDirectory = "",
         AppCreateUserid = "",
         AppLastUpdateUserDirectory = "",
         AppLastUpdateUserid = "",
         DbCreateUserid = "",
         DbLastUpdateUserid = "",
         IsDisabled = false,
         ConcurrencyControlNumber = 1
     });
 }
コード例 #7
0
ファイル: PersonHelper.cs プロジェクト: asanchezr/PSP
 /// <summary>
 /// Create a new instance of an Person.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="surname"></param>
 /// <param name="firstName"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public static Entity.PimsPerson CreatePerson(this PimsContext context, long id, string surname, string firstName, Entity.PimsAddress address = null)
 {
     address ??= EntityHelper.CreateAddress(context, id, "1234 St");
     return(new Entity.PimsPerson(surname, firstName, address)
     {
         PersonId = id,
         ConcurrencyControlNumber = 1,
         AppCreateUserDirectory = "",
         AppCreateUserid = "",
         AppLastUpdateUserDirectory = "",
         AppLastUpdateUserid = "",
         DbCreateUserid = "",
         DbLastUpdateUserid = "",
         IsDisabled = false
     });
 }
コード例 #8
0
ファイル: BuildingHelper.cs プロジェクト: bcgov/PSP
        /// <summary>
        /// Creates a new instance of a Building.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="parcel"></param>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Building CreateBuilding(this PimsContext context, Entity.Parcel parcel, int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null)
        {
            name ??= $"l{id}";
            agency ??= parcel?.Agency ?? context.Agencies.FirstOrDefault() ?? EntityHelper.CreateAgency(id);
            var address = (parcel == null ? EntityHelper.CreateAddress(context, id, "1234 Street", null, "V9C9C9") :
                           EntityHelper.CreateAddress(id, parcel.Address.Address1, parcel.Address.Address2, parcel.Address.AdministrativeArea, parcel.Address.Province, parcel.Address.Postal));
            var predominateUse   = context.BuildingPredominateUses.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingPredominateUse("use");;
            var constructionType = context.BuildingConstructionTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingConstructionType("type");
            var occupantType     = context.BuildingOccupantTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingOccupantType("occupant");
            var classification   = context.PropertyClassifications.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification");

            var building = new Entity.Building(parcel, lat, lng)
            {
                Id                         = id,
                Name                       = name,
                ProjectNumbers             = projectNumber,
                AgencyId                   = agency.Id,
                Agency                     = agency,
                AddressId                  = address.Id,
                Address                    = address,
                Classification             = classification,
                ClassificationId           = classification.Id,
                Description                = $"description-{id}",
                BuildingPredominateUse     = predominateUse,
                BuildingPredominateUseId   = predominateUse.Id,
                BuildingConstructionType   = constructionType,
                BuildingConstructionTypeId = constructionType.Id,
                BuildingOccupantType       = occupantType,
                BuildingOccupantTypeId     = occupantType.Id,
                CreatedById                = Guid.NewGuid(),
                CreatedOn                  = DateTime.UtcNow,
                UpdatedById                = Guid.NewGuid(),
                UpdatedOn                  = DateTime.UtcNow,
                RowVersion                 = new byte[] { 12, 13, 14 }
            };

            if (parcel != null)
            {
                var parcelBuilding = new Entity.ParcelBuilding(parcel, building);
            }
            context.Buildings.Add(building);
            return(building);
        }
コード例 #9
0
ファイル: BuildingHelper.cs プロジェクト: bcgov/PSP
        /// <summary>
        /// Creates a new instance of a Building.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="projectNumber"></param>
        /// <param name="name"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        public static Entity.Building CreateBuilding(int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null)
        {
            projectNumber ??= $"p{id}";
            agency ??= agency ?? EntityHelper.CreateAgency(id);
            var address          = EntityHelper.CreateAddress(id, "1234 Street", null, "V9C9C9");
            var predominateUse   = EntityHelper.CreateBuildingPredominateUse("use");
            var constructionType = EntityHelper.CreateBuildingConstructionType("type");
            var occupantType     = EntityHelper.CreateBuildingOccupantType("occupant");
            var classification   = EntityHelper.CreatePropertyClassification("classification");

            return(new Entity.Building()
            {
                Id = id,
                ProjectNumbers = $"[\"{projectNumber}\"]",
                AgencyId = agency.Id,
                Agency = agency,
                Name = name,
                AddressId = address.Id,
                Address = address,
                Location = new Point(lng, lat)
                {
                    SRID = 4326
                },
                Classification = classification,
                ClassificationId = classification.Id,
                Description = $"description-{id}",
                BuildingPredominateUse = predominateUse,
                BuildingPredominateUseId = predominateUse.Id,
                BuildingConstructionType = constructionType,
                BuildingConstructionTypeId = constructionType.Id,
                BuildingOccupantType = occupantType,
                BuildingOccupantTypeId = occupantType.Id,
                CreatedById = Guid.NewGuid(),
                CreatedOn = DateTime.UtcNow,
                UpdatedById = Guid.NewGuid(),
                UpdatedOn = DateTime.UtcNow,
                RowVersion = new byte[] { 12, 13, 14 },
                PropertyTypeId = 1,
            });
        }
コード例 #10
0
ファイル: BuildingHelper.cs プロジェクト: agalbrai/PIMS
        /// <summary>
        /// Creates a new instance of a Building.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="parcel"></param>
        /// <param name="id"></param>
        /// <param name="localId"></param>
        /// <param name="lat"></param>
        /// <param name="lng"></param>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Entity.Building CreateBuilding(this PimsContext context, Entity.Parcel parcel, int id, string projectNumber = null, string localId = null, int lat = 0, int lng = 0, Entity.Agency agency = null)
        {
            localId ??= $"l{id}";
            agency ??= parcel.Agency;
            var address          = EntityHelper.CreateAddress(id, parcel.Address.Address1, parcel.Address.Address2, parcel.Address.City, parcel.Address.Province, parcel.Address.Postal);
            var predominateUse   = context.BuildingPredominateUses.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingPredominateUse("use");;
            var constructionType = context.BuildingConstructionTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingConstructionType("type");
            var occupantType     = context.BuildingOccupantTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingOccupantType("occupant");
            var classification   = context.PropertyClassifications.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification");

            var building = new Entity.Building(parcel, lat, lng)
            {
                Id                         = id,
                ProjectNumber              = projectNumber,
                LocalId                    = localId,
                AgencyId                   = agency.Id,
                Agency                     = agency,
                AddressId                  = address.Id,
                Address                    = address,
                Classification             = classification,
                ClassificationId           = classification.Id,
                Description                = $"description-{id}",
                BuildingPredominateUse     = predominateUse,
                BuildingPredominateUseId   = predominateUse.Id,
                BuildingConstructionType   = constructionType,
                BuildingConstructionTypeId = constructionType.Id,
                BuildingOccupantType       = occupantType,
                BuildingOccupantTypeId     = occupantType.Id,
                CreatedById                = Guid.NewGuid(),
                CreatedOn                  = DateTime.UtcNow,
                UpdatedById                = Guid.NewGuid(),
                UpdatedOn                  = DateTime.UtcNow,
                RowVersion                 = new byte[] { 12, 13, 14 }
            };

            parcel.Buildings.Add(building);
            context.Buildings.Add(building);
            return(building);
        }
コード例 #11
0
        /// <summary>
        /// Creates a default list of Organization.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="identifierType"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static List <Entity.PimsOrganization> CreateDefaultOrganizations(Entity.PimsOrganizationType type = null, Entity.PimsOrgIdentifierType identifierType = null, Entity.PimsAddress address = null)
        {
            type ??= EntityHelper.CreateOrganizationType("Type 1");
            identifierType ??= EntityHelper.CreateOrganizationIdentifierType("Identifier 1");
            return(new List <Entity.PimsOrganization>()
            {
                // Parent organizations
                new Entity.PimsOrganization("Ministry of Advanced Education, Skills & Training", type, identifierType, address ?? EntityHelper.CreateAddress(1000))
                {
                    Id = 1, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Citizens Service", type, identifierType, address ?? EntityHelper.CreateAddress(1002))
                {
                    Id = 2, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Corporate Services for the Natural Resources Sector", type, identifierType, address ?? EntityHelper.CreateAddress(1003))
                {
                    Id = 3, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Education", type, identifierType, address ?? EntityHelper.CreateAddress(1004))
                {
                    Id = 4, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Finance", type, identifierType, address ?? EntityHelper.CreateAddress(1005))
                {
                    Id = 5, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Forests, Lands, Natural Resources", type, identifierType, address ?? EntityHelper.CreateAddress(1006))
                {
                    Id = 6
                },
                new Entity.PimsOrganization("Ministry of Health", type, identifierType, address ?? EntityHelper.CreateAddress(1007))
                {
                    Id = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Municipal Affairs & Housing", type, identifierType, address ?? EntityHelper.CreateAddress(1008))
                {
                    Id = 8, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Ministry of Transportation and Infrastructure", type, identifierType, address ?? EntityHelper.CreateAddress(1009))
                {
                    Id = 9, ConcurrencyControlNumber = 1
                },

                // Sub-organizations
                new Entity.PimsOrganization("Ministry Lead", type, identifierType, address ?? EntityHelper.CreateAddress(1010))
                {
                    Id = 10, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Acting Deputy Minister", type, identifierType, address ?? EntityHelper.CreateAddress(1011))
                {
                    Id = 11, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Executive Director", type, identifierType, address ?? EntityHelper.CreateAddress(1012))
                {
                    Id = 12, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Fraser Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1013))
                {
                    Id = 13, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Interior Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1014))
                {
                    Id = 14, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Northern Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1015))
                {
                    Id = 15, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Provincial Health Services Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1016))
                {
                    Id = 16, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Vancouver Coastal Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1017))
                {
                    Id = 17, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                },
                new Entity.PimsOrganization("Vancouver Island Health Authority", type, identifierType, address ?? EntityHelper.CreateAddress(1018))
                {
                    Id = 18, PrntOrganizationId = 7, ConcurrencyControlNumber = 1
                }
            });
        }
コード例 #12
0
ファイル: AccessRequestHelper.cs プロジェクト: asanchezr/PSP
        /// <summary>
        /// Create a new instance of an AccessRequest for the specified user.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user"></param>
        /// <param name="role"></param>
        /// <param name="organization"></param>
        /// <returns></returns>
        public static Entity.PimsAccessRequest CreateAccessRequest(long id, Entity.PimsUser user, Entity.PimsRole role, Entity.PimsOrganization organization)
        {
            user ??= EntityHelper.CreateUser("test");
            role ??= EntityHelper.CreateRole("Real Estate Manager");
            var accessRequest = new Entity.PimsAccessRequest()
            {
                AccessRequestId = id,
                UserId          = user.Id,
                User            = user,
                RoleId          = role.Id,
                Role            = role
            };

            organization ??= EntityHelper.CreateOrganization(id, "test", EntityHelper.CreateOrganizationType("Type 1"), EntityHelper.CreateOrganizationIdentifierType("Identifier 1"), EntityHelper.CreateAddress(id));
            accessRequest.PimsAccessRequestOrganizations.Add(new Entity.PimsAccessRequestOrganization()
            {
                AccessRequestId = id,
                AccessRequest   = accessRequest,
                OrganizationId  = organization.Id,
                Organization    = organization
            });

            return(accessRequest);
        }