private AccountActionResponse ActionSeveAccountFunc(AccountDto savedAccount, AccountDto requestedAccount, AccountActionRequest request, string Role) { AccountDto resultAccount = new AccountDto(); request.Account = resultAccount; List <AccountDto> accountsList = _baseService.GetAccounts(request).ToList(); //if exist then update if (accountsList.Find(x => x.UserName == requestedAccount.UserName || x.AccountId == requestedAccount.AccountId) != null) { requestedAccount.Passwords.ForEach(x => { _baseService.UpdatePassword(x); }); resultAccount = _baseService.UpdateAccount(requestedAccount, Role, false); } else { requestedAccount.AccountId = Guid.NewGuid(); requestedAccount.Passwords.ForEach(x => { _baseService.AddNewPassword(x); }); resultAccount = _baseService.AddNewAccount(requestedAccount); } return(new AccountActionResponse() { Accounts = new List <AccountDto>() { resultAccount } }); }