예제 #1
0
파일: UserHelper.cs 프로젝트: asanchezr/PSP
        /// <summary>
        /// Create a new instance of an AccessRequest for a default user.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="keycloakUserId"></param>
        /// <param name="username"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="person"></param>
        /// <param name="role"></param>
        /// <param name="organization"></param>
        /// <returns></returns>
        public static Entity.PimsUser CreateUser(long id, Guid keycloakUserId, string username, string firstName = "given name", string lastName = "surname", Entity.PimsRole role = null, Entity.PimsOrganization organization = null, Entity.PimsAddress address = null)
        {
            organization ??= EntityHelper.CreateOrganization(id, "Organization 1");
            role ??= EntityHelper.CreateRole("Real Estate Manager");
            var person = new Entity.PimsPerson(lastName, firstName, address);

            person.PimsContactMethods = new List <Entity.PimsContactMethod>();
            var user = new Entity.PimsUser(keycloakUserId, username, person)
            {
                Id        = id,
                IssueDate = DateTime.UtcNow,
                ConcurrencyControlNumber = 1
            };

            user.PimsUserRoles.Add(new Entity.PimsUserRole()
            {
                Role = role, RoleId = role.Id, User = user, UserId = user.Id
            });
            user.PimsUserOrganizations.Add(new Entity.PimsUserOrganization()
            {
                Organization = organization, OrganizationId = organization.Id, User = user, UserId = user.Id
            });

            return(user);
        }
예제 #2
0
 /// <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
     });
 }
예제 #3
0
 /// <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
     });
 }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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
                }
            });
        }
예제 #7
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
     });
 }
예제 #8
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);
        }