/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(ClientsDto input) { try { _dbContext.Ado.BeginTran(); var model = _mapper.Map <ClientsDto, Clients>(input); if (model.Id > 0) { await _dbContext.Updateable(model).ExecuteCommandAsync(); await SaveClientGrantTypes(input.AllowedGrantTypes, model.Id, true); await SaveClientScope(input.AllowedScopes, model.Id, true); await SaveClientSecret(input.ClientSecrets, model.Id, true); _dbContext.Ado.CommitTran(); return; } var mid = await _dbContext.Insertable(model).ExecuteReturnIdentityAsync(); await SaveClientGrantTypes(input.AllowedGrantTypes, mid); await SaveClientScope(input.AllowedScopes, mid); await SaveClientSecret(input.ClientSecrets, mid); _dbContext.Ado.CommitTran(); } catch (Exception ex) { _dbContext.Ado.RollbackTran(); throw ex; } }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(UserDto input) { input.KeyId = input.KeyId ?? Guid.Empty; var model = _mapper.Map <UserDto, User>(input); if (model.KeyId != Guid.Empty) { model.UpdateTime = DateTime.Now; if (model.Password.IsNotNullAndWhiteSpace()) { model.Salt = Randoms.CreateRandomValue(8, false); model.Password = $"{model.Password}+_(QVQ)_+{model.Salt}".ToMd5(); await _dbContext.Updateable(model) .IgnoreColumns(it => new { it.Account, it.CreateTime }) .ExecuteCommandAsync(); } else { await _dbContext.Updateable(model) .IgnoreColumns(it => new { it.Account, it.Password, it.Salt, it.CreateTime }) .ExecuteCommandAsync(); } } else { model.CreateTime = DateTime.Now; model.UpdateTime = DateTime.Now; model.Salt = Randoms.CreateRandomValue(8, false); model.Password = $"{model.Password}+_(QVQ)_+{model.Salt}".ToMd5(); await _dbContext.Insertable(model).ExecuteCommandAsync(); } }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(ApiResource input) { try { _dbContext.Ado.BeginTran(); if (input.Id > 0) { var scope = await _dbContext.Queryable <ApiScope>().FirstAsync(o => o.ApiResourceId == input.Id); input.Updated = DateTime.Now; await _dbContext.Updateable(input).IgnoreColumns(it => new { it.Created }) .ExecuteCommandAsync(); if (scope != null) { scope.Name = input.Name; scope.DisplayName = input.DisplayName; scope.Description = input.Description; await _dbContext.Updateable(scope).IgnoreColumns(it => new { it.ApiResourceId }) .ExecuteCommandAsync(); } _dbContext.Ado.CommitTran(); return; } input.Created = DateTime.Now; input.NonEditable = 0; var rid = await _dbContext.Insertable(input).ExecuteReturnIdentityAsync(); await _dbContext.Insertable(new ApiScope { ApiResourceId = rid, Description = input.Description, DisplayName = input.DisplayName, Emphasize = false, Name = input.Name, Required = false, ShowInDiscoveryDocument = true }).ExecuteCommandAsync(); _dbContext.Ado.CommitTran(); } catch (Exception ex) { _dbContext.Ado.RollbackTran(); throw ex; } }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(ConfigReRoutes input) { if (input.KeyId > 0) { await _dbContext.Updateable(input).ExecuteCommandAsync(); return; } await _dbContext.Insertable(input).ExecuteCommandAsync(); }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(ClientGroup input) { if (input.ClientGroupId > 0) { await _dbContext.Updateable(input).ExecuteCommandAsync(); return; } await _dbContext.Insertable(input).ExecuteCommandAsync(); }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(ReRouteGroupAuth input) { if (input.AuthId > 0) { await _dbContext.Updateable(input).ExecuteCommandAsync(); return; } await _dbContext.Insertable(input).ExecuteCommandAsync(); }
/// <summary> /// 编辑信息 /// </summary> public async Task EditModel(RoleDto input) { input.KeyId = input.KeyId ?? Guid.Empty; var model = _mapper.Map <RoleDto, Role>(input); if (model.KeyId != Guid.Empty) { await _dbContext.Updateable(model) .IgnoreColumns(it => new { it.CreateTime }) .ExecuteCommandAsync(); } else { model.CreateTime = DateTime.Now; await _dbContext.Insertable(model).ExecuteCommandAsync(); } }