public UserRole(IUser User, UserRoleRecord UserRole, HttpRequestMessage m) { Type = "Role"; // part fields Id = UserRole.Id; UserId = User.Id; Name = UserRole.Name; Description = UserRole.Description; IsDefault = UserRole.IsDefaultRole; string Username = User.UserName; // computed fields UriBuilder b = new UriBuilder(m.RequestUri.Scheme, m.RequestUri.Host, m.RequestUri.Port); b.Path = "/v1/user/profile('" + Username + "')/roles/('" + Name + "')"; link = b.Uri; }
public bool CreateUserForApplicationRecord(UserProfilePart profilePart, ApplicationRecord appRecord) { UserProfilePartRecord profileRecord = _userprofileRepository.Get(profilePart.Id); if (profileRecord == null) { return(false); } var utcNow = _clock.UtcNow; var record = profileRecord.Applications.FirstOrDefault(x => x.ApplicationRecord.Name == appRecord.Name); if (record == null) { profileRecord.Applications.Add(new UserApplicationRecord { UserProfilePartRecord = profileRecord, ApplicationRecord = appRecord, RegistrationStart = utcNow }); TriggerSignal(); } if (profileRecord.Roles == null || profileRecord.Roles.Count == 0) { UserRoleRecord defaultrole = _applicationsService.GetDefaultRole(appRecord); profileRecord.Roles.Add(new UserUserRoleRecord { UserProfilePartRecord = profileRecord, UserRoleRecord = defaultrole }); } return(true); }