public void AddCredentialValueAndAssociatedUserGroupToExistingDaUserGroup(CredentialValue credentialValue, string sourceApplicationUrl, int daUserGroupId, out UserGroup createdUserGroup, out CredentialValue createdLafUserGroupCredentialValueForExistingDaUserGroup) { UserGroupCredentialValue createdUserGroupCredentialValue; var lafUserGroupCredentialId = this.GetIdForLafUserGroupCredential(); InsertCredentialValueAndAssociatedUserGroup(credentialValue, out createdUserGroup, out createdUserGroupCredentialValue); credentialValue.AssociatedUserGroup = createdUserGroup; credentialValue.AssociatedUserGroupCredentialValue = createdUserGroupCredentialValue; createdLafUserGroupCredentialValueForExistingDaUserGroup = new CredentialValue { CredentialId = lafUserGroupCredentialId, SourceApplicationId = createdUserGroup.ApplicationId, Value = createdUserGroup.UserGroupId.ToString(CultureInfo.InvariantCulture), Description = string.Format("LAF {0} LafUserGroup", createdUserGroup.Name) }; InsertCredentialValue(createdLafUserGroupCredentialValueForExistingDaUserGroup); var userGroupCredentialValue = new UserGroupCredentialValue { CredentialValueId = createdLafUserGroupCredentialValueForExistingDaUserGroup.CredentialValueId, UserGroupId = daUserGroupId }; InsertUserGroupCredentialValue(userGroupCredentialValue); }
//TODO - move these UserGroup methods into their own UserGroup Repository, and use dependency injection to allow the Credential and UserGroup repositories to use each other's methods. // I wish whole-heartedly and unreservedly to apologise to all who may look at this code in times to come, for the haphazard methods, with their inexplicable // mixes of functionality (I give you AddDevolvedAdminUserGroupForGivenUserGroup and AddDevolvedAdminUserGroupForGivenUserGroup by way of example), for the bits that are // in the wrong place, and for - well, just for the mess, really. In my defence, this has been written so bittily, so hurriedly, and with so many interruptions // that the fact it works at all is a small miracle of which I am, dare I boast it, even a little proud, despite its manifold horrors, because it was written in // adversity, and with project deadlines coming at me from all directions. // Nonetheless, it is what it is, and I throw myself on the mercy of the court. Please try to be understanding. PM 18/09/2013 public void AddDevolvedAdminUserGroupForGivenUserGroup(string name, string description, UserGroup userGroupForWhichADevolvedAdminUserGroupIsToBeCreated, out UserGroup createdDaUserGroup, out CredentialValue createdLafUserGroupCredentialValueForCreatedDaUserGroup) { var lafUserGroupCredentialId = GetIdForLafUserGroupCredential(); createdDaUserGroup = new UserGroup { Description = description, Name = name }; InsertDevolvedAdminUserGroup(createdDaUserGroup); InsertDevolvedAdminRoleUserGroupCredentialValue(createdDaUserGroup.UserGroupId); createdLafUserGroupCredentialValueForCreatedDaUserGroup = new CredentialValue { CredentialId = lafUserGroupCredentialId, SourceApplicationId = userGroupForWhichADevolvedAdminUserGroupIsToBeCreated.ApplicationId, Value = userGroupForWhichADevolvedAdminUserGroupIsToBeCreated.UserGroupId.ToString(CultureInfo.InvariantCulture), Description = string.Format("LAF {0} LafUserGroup", userGroupForWhichADevolvedAdminUserGroupIsToBeCreated.Name) }; InsertCredentialValue(createdLafUserGroupCredentialValueForCreatedDaUserGroup); var userGroupCredentialValue = new UserGroupCredentialValue { CredentialValueId = createdLafUserGroupCredentialValueForCreatedDaUserGroup.CredentialValueId, UserGroupId = createdDaUserGroup.UserGroupId }; InsertUserGroupCredentialValue(userGroupCredentialValue); }
public void AddUserGroupCredentialValue(UserGroupCredentialValue userGroupCredentialValue) { using (var operation = BeginOperation()) { this.userGroupRepository.Save(userGroupCredentialValue); operation.Complete(); } this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded, AuditInformation.Create() .WithUserGroupCredentialValues(userGroupCredentialValue)); }
public void Save(UserGroupCredentialValue value) { const string RelationshipStoredProcedureName = "[LAF].[csp_InsertUserGroupCredentialValueWithExpiryDate]"; var parameters = new DynamicParameters(new { userGroupId = value.UserGroupId, credentialValueId = value.CredentialValueId, value.ExpiryDate }); var foundId = this.RunQuery <int>(RelationshipStoredProcedureName, parameters).FirstOrDefault(); value.UserGroupCredentialValueId = Convert.ToInt32(foundId); }
private void InsertCredentialValueAndAssociatedUserGroup(CredentialValue credentialValue, out UserGroup createdUserGroup, out UserGroupCredentialValue createdUserGroupCredentialValue) { InsertCredentialValue(credentialValue); createdUserGroup = new UserGroup { Description = credentialValue.Description, Name = credentialValue.Value }; InsertUserGroupWithGeneratedApplicationDetails(createdUserGroup, credentialValue.CredentialId); createdUserGroupCredentialValue = new UserGroupCredentialValue { CredentialValueId = credentialValue.CredentialValueId, UserGroupId = createdUserGroup.UserGroupId }; InsertUserGroupCredentialValue(createdUserGroupCredentialValue); }