示例#1
0
        public async Task <TermsOfServiceModel> UpdateAsync(TermsOfServiceModel termsOfService)
        {
            a3SContext.Entry(termsOfService).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(termsOfService);
        }
示例#2
0
        public async Task <PermissionModel> UpdateAsync(PermissionModel permission)
        {
            a3SContext.Entry(permission).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(permission);
        }
示例#3
0
        public async Task <SubRealmModel> UpdateAsync(SubRealmModel subRealm)
        {
            a3SContext.Entry(subRealm).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(subRealm);
        }
示例#4
0
        public async Task <FunctionModel> UpdateAsync(FunctionModel function)
        {
            a3SContext.Entry(function).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(function);
        }
        public async Task <ApplicationDataPolicyModel> UpdateAsync(ApplicationDataPolicyModel applicationDataPolicy)
        {
            a3SContext.Entry(applicationDataPolicy).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(applicationDataPolicy);
        }
示例#6
0
        public async Task <TeamModel> UpdateAsync(TeamModel team)
        {
            a3SContext.Entry(team).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(team);
        }
        public async Task <ProfileModel> UpdateAsync(ProfileModel profile)
        {
            a3SContext.Entry(profile).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(profile);
        }
示例#8
0
        public async Task <UserModel> UpdateAsync(UserModel user)
        {
            a3SContext.Entry(user).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(user);
        }
示例#9
0
        public async Task <RoleModel> UpdateAsync(RoleModel role)
        {
            a3SContext.Entry(role).State = EntityState.Modified;
            await a3SContext.SaveChangesAsync();

            return(role);
        }
示例#10
0
        private void UpdateUserField(UserModel appUser, string userField, string value)
        {
            switch (userField.ToLower())
            {
            case "username":
                appUser.UserName = value;
                a3SContext.Entry(appUser).State = EntityState.Modified;
                break;

            case "firstname":
                appUser.FirstName = value;
                a3SContext.Entry(appUser).State = EntityState.Modified;
                break;

            case "surname":
                appUser.Surname = value;
                a3SContext.Entry(appUser).State = EntityState.Modified;
                break;

            case "email":
                appUser.Email = value;
                a3SContext.Entry(appUser).State = EntityState.Modified;
                break;

            case "avatar":
                var binaryFormatter = new BinaryFormatter();

                using (var memoryStream = new MemoryStream())
                {
                    binaryFormatter.Serialize(memoryStream, value);
                    appUser.Avatar = memoryStream.ToArray();
                }

                a3SContext.Entry(appUser).State = EntityState.Modified;
                break;
            }
        }
        public async Task <LdapAuthenticationModeModel> UpdateAsync(LdapAuthenticationModeModel ldapAuthenticationMode)
        {
            // Record plain text password and clear from model
            string password = ldapAuthenticationMode.Password;

            ldapAuthenticationMode.Password = string.Empty;

            a3SContext.Entry(ldapAuthenticationMode).State = EntityState.Modified;

            // Replace Ldap Attribute Links
            a3SContext.RemoveRange(a3SContext.LdapAuthenticationModeLdapAttribute.Where(x => x.LdapAuthenticationModeId == ldapAuthenticationMode.Id));
            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);
            }
        }