示例#1
0
        public async Task <PermissionModel> CreateAsync(PermissionModel permission)
        {
            a3SContext.Permission.Add(permission);
            await a3SContext.SaveChangesAsync();

            return(permission);
        }
示例#2
0
        public async Task <SubRealmModel> CreateAsync(SubRealmModel subRealm)
        {
            a3SContext.Add(subRealm);
            await a3SContext.SaveChangesAsync();

            return(subRealm);
        }
示例#3
0
        public async Task <FunctionModel> CreateAsync(FunctionModel function)
        {
            a3SContext.Function.Add(function);
            await a3SContext.SaveChangesAsync();

            return(function);
        }
        public async Task <ApplicationDataPolicyModel> CreateAsync(ApplicationDataPolicyModel applicationDataPolicy)
        {
            a3SContext.ApplicationDataPolicy.Add(applicationDataPolicy);
            await a3SContext.SaveChangesAsync();

            return(applicationDataPolicy);
        }
        public async Task <ProfileModel> CreateAsync(ProfileModel profile)
        {
            a3SContext.Add(profile);
            await a3SContext.SaveChangesAsync();

            return(profile);
        }
示例#6
0
        public async Task <ApplicationFunctionModel> CreateAsync(ApplicationFunctionModel applicationFunction)
        {
            a3SContext.ApplicationFunction.Add(applicationFunction);
            await a3SContext.SaveChangesAsync();

            return(applicationFunction);
        }
示例#7
0
        public async Task <TeamModel> CreateAsync(TeamModel team)
        {
            a3SContext.Team.Add(team);
            await a3SContext.SaveChangesAsync();

            return(team);
        }
示例#8
0
        public async Task DeleteAsync(UserModel user)
        {
            // Delete all relations
            if (user.UserClaims != null && user.UserClaims.Count > 0)
            {
                a3SContext.ApplicationUserClaims.RemoveRange(user.UserClaims);
            }

            if (user.UserRoles != null && user.UserRoles.Count > 0)
            {
                a3SContext.UserRole.RemoveRange(user.UserRoles);
            }

            if (user.UserTeams != null && user.UserTeams.Count > 0)
            {
                a3SContext.UserTeam.RemoveRange(user.UserTeams);
            }


            // Mark user as deleted (rename username and email field to support creating a new record in the future)
            user.IsDeleted          = true;
            user.DeletedTime        = DateTime.UtcNow;
            user.UserName           = $"{user.UserName} - Deleted";
            user.Email              = $"{user.Email} - Deleted";
            user.NormalizedUserName = user.UserName.ToUpper();
            user.NormalizedEmail    = user.Email.ToUpper();
            await UpdateAsync(user);

            await a3SContext.SaveChangesAsync();
        }
示例#9
0
        public async Task <RoleModel> CreateAsync(RoleModel role)
        {
            a3SContext.Role.Add(role);
            await a3SContext.SaveChangesAsync();

            return(role);
        }
示例#10
0
        public async Task <TermsOfServiceModel> CreateAsync(TermsOfServiceModel termsOfService, bool autoAssignToPreviouslyLinkedTeams)
        {
            // Save new agreement version
            a3SContext.TermsOfService.Add(termsOfService);
            await a3SContext.SaveChangesAsync();

            if (autoAssignToPreviouslyLinkedTeams)
            {
                await AssignNewTermsOfServiceEntryToTeams(termsOfService.Id);
                await ArchiveTermsOfServiceAcceptanceRecords(termsOfService.AgreementName);
            }

            return(termsOfService);
        }
        public async Task <LdapAuthenticationModeModel> CreateAsync(LdapAuthenticationModeModel ldapAuthenticationMode)
        {
            string password = ldapAuthenticationMode.Password;

            ldapAuthenticationMode.Password = string.Empty;

            a3SContext.LdapAuthenticationMode.Add(ldapAuthenticationMode);
            await a3SContext.SaveChangesAsync();

            // Now store encrypted password
            await StoreEncryptedPassword(ldapAuthenticationMode.Id, password);

            return(ldapAuthenticationMode);
        }
示例#12
0
        public async override Task SetTokenAsync(UserModel user, string loginProvider, string name, string value, CancellationToken cancellationToken)
        {
            bool encrypt = (name == tokenOptions.GetAuthenticatorKeyName());
            bool isAutomaticallyVerified = (name == tokenOptions.GetRecoverCodesName());

            var tokenEntity =
                a3SContext.UserToken.SingleOrDefault(
                    l =>
                    l.Name == name && l.LoginProvider == loginProvider &&
                    l.UserId == user.Id);

            if (tokenEntity != null)
            {
                tokenEntity.Value = (encrypt ? string.Empty : value);

                if (isAutomaticallyVerified)
                {
                    tokenEntity.IsVerified = true;
                }

                a3SContext.Entry(tokenEntity).State = EntityState.Modified;
            }
            else
            {
                a3SContext.UserToken.Add(new UserTokenModel
                {
                    UserId        = user.Id,
                    LoginProvider = loginProvider,
                    Name          = name,
                    Value         = (encrypt ? string.Empty : value),
                    IsVerified    = isAutomaticallyVerified
                });
            }

            await a3SContext.SaveChangesAsync();

            if (encrypt)
            {
                await StoreEncryptedValue(user, loginProvider, name, value);
            }
        }