コード例 #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
ファイル: 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);
        }