public async Task <Account> Update(UpdateAccountInput input) { var account = await GetAccountById(input.Id); if (!account.Email.Equals(input.Email)) { var exsitAccountCount = await _repository.GetCountAsync <Account>(p => p.Email == input.Email); if (exsitAccountCount > 0) { throw new BusinessException($"系统中已经存在Email为{input.Email}的账号"); } } if (!account.Name.Equals(input.Name)) { var exsitAccountCount = await _repository.GetCountAsync <Account>(p => p.Name == input.Name); if (exsitAccountCount > 0) { throw new BusinessException($"系统中已经存在Name为{input.Name}的账号"); } } await _accountCache.RemoveAsync($"Account:Name:{account.Name}"); account = input.MapTo(account); await _repository.UpdateAsync(account); return(account); }
public async Task <GetAccountOutput> Update(UpdateAccountInput input) { var account = await _accountDomainService.Update(input); return(account.MapTo <GetAccountOutput>()); }