/// <summary> /// 修改账号信息 /// </summary> /// <param name="modifiyAccountDto"></param> /// <returns></returns> public async Task UpdateAccountAsync(ModifiyAccountDto modifiyAccountDto) { var existmodel = await _accountRepository.SingleOrDefaultAsync(c => c.Id == modifiyAccountDto.Id); if (existmodel == null) { throw new ArgumentException("该账号不存在了"); } if (existmodel.Role != null && existmodel.Role.IsSuperAdmin) { throw new ArgumentException("您是超级管理员不能被停用"); } var appUser = Map <ModifiyAccountDto, Account>(modifiyAccountDto, existmodel); if (modifiyAccountDto.Password != null) { appUser.Password = passwordHandler.GenerateEncryptPassword(modifiyAccountDto.Password); } await _accountRepository.UpdateAsync(appUser); await _accountRepository.UnitOfWork.SaveChangesAsync(); }
public async Task <ApiResult> UpdateAccountAsync(ModifiyAccountDto modifiyAccountDto) { await passportService.UpdateAccountAsync(modifiyAccountDto); return(ApiResult.Success); }