query=$@"UPDATE ""AccountCredential"" ac SET ""Active"" = FALSE FROM ""Account"" act
WHERE act.""AccountId"" = ac.""AccountId"" AND act.""Email"" = '{account.Email}';
INSERT INTO ""AccountCredential""(""AccountId"", ""PasswordHash"", ""CreatedBy"", ""CreatedDate"")
SELECT act.""AccountId"", '{passwordHash}', act.""AccountId"", NOW() AT TIME ZONE 'UTC' FROM ""Account"" act
WHERE act.""Email"" = '{account.Email}';";
}
elseif(string.IsNullOrEmpty(account.Email))
{
query=$@"UPDATE ""AccountCredential"" ac SET ""Active"" = FALSE FROM ""Account"" act
WHERE act.""AccountId"" = ac.""AccountId"" AND act.""Mobile"" = '{account.Mobile}' AND act.""CountryId"" = '{account.CountryId}';
INSERT INTO ""AccountCredential""(""AccountId"", ""PasswordHash"", ""CreatedBy"", ""CreatedDate"")
SELECT act.""AccountId"", '{passwordHash}', act.""AccountId"", NOW() AT TIME ZONE 'UTC' FROM ""Account"" act
WHERE act.""Mobile"" = '{account.Mobile}' AND act.""CountryId"" = '{account.CountryId}';";
}
else
{
query=$@"UPDATE ""AccountCredential"" ac SET ""Active"" = FALSE FROM ""Account"" act
WHERE act.""AccountId"" = ac.""AccountId"" AND act.""Email"" = '{account.Email}' AND act.""Mobile"" = '{account.Mobile}' AND act.""CountryId"" = '{account.CountryId}';
INSERT INTO ""AccountCredential""(""AccountId"", ""PasswordHash"", ""CreatedBy"", ""CreatedDate"")
SELECT act.""AccountId"", '{passwordHash}', act.""AccountId"", NOW() AT TIME ZONE 'UTC' FROM ""Account"" act
WHERE act.""Email"" = '{account.Email}' AND act.""Mobile"" = '{account.Mobile}' AND act.""CountryId"" = '{account.CountryId}';";