【发布时间】:2020-09-22 20:26:47
【问题描述】:
我有新的用户数据(我想导入/更新它)。通过用户数据查找帐户。 我想根据用户数据找到的帐户更新或创建新帐户 :
if (accountById != null)
{
if (accountByNumber != null)
{
if (accountById.Id == accountByNumber.Id)
{
if (_isSpecialData)
{
AddUserDataToAccount(userData, accountByNumber);
if (userData.Status == Blocked) return;
}
}
else
{
_log.Error($"Bad");
return;
}
}
else
{
AddUserDataToAccount(userData, accountById);
}
}
else
{
if (accountByNumber != null)
{
if (accountByNumber.RefNo == null)
{
SetAccountAdditionalId(accountByNumber, userData.AdditionalId);
if (_isSpecialData)
{
AddUserDataToAccount(userData, accountByNumber);
if (userData.Status == Blocked) return;
}
}
else
{
_log.Error($"Bad");
return;
}
}
else
{
CreateCardAndProfile2(userData, out createdNewAccount);
CreateNewAccount(userData, out createdNewAccount);
}
}
UpdateAccountData(userData, createdNewAccount);
上面的方法可行,但我想知道有没有什么方法可以让它更易读、更优化?
【问题讨论】:
-
像这些问题是 Stack Overflow 的主题。改为在codereview.stackexchange.com 上发帖
-
谢谢@MathewHD,我不知道这个网站。我在这里发帖codereview.stackexchange.com/questions/249680/…
标签: c# .net if-statement optimization nested