/// <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); }
/// <summary> /// Create a new instance of an AccessRequest for a default user. /// </summary> /// <param name="id"></param> /// <param name="username"></param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="role"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.User CreateUser(Guid id, string username, string firstName = "given name", string lastName = "surname", Entity.Role role = null, Entity.Agency agency = null) { var user = new Entity.User(id, username, $"{firstName}.{lastName}@email.com") { DisplayName = $"{lastName}, {firstName}", RowVersion = new byte[] { 12, 13, 14 } }; user.Roles.Add(new Entity.UserRole(user, role ?? EntityHelper.CreateRole("Real Estate Manager"))); user.Agencies.Add(new Entity.UserAgency(user, agency ?? EntityHelper.CreateAgency())); return(user); }
/// <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); }