public async Task <IWrappedResponse> GetAllowedDestinationAccounts() { var partnerAccount = _olmaPostingAccountRepo.FindAll().IgnoreQueryFilters().FirstOrDefault(a => a.CustomerDivisions.Any(c => c.Customer.Organization.Name.Contains("Dpl"))); var shipperAccount = _olmaPostingAccountRepo.FindAll().IgnoreQueryFilters().Where(a => a.CustomerDivisions.Any(d => d.Customer.Users.Select(u => u.User).All(u => u.Role == UserRole.Shipper)) && !a.IsDeleted) .FirstOrDefault(a => !AuthData.GetPostingAccountIds().Contains(a.Id) && a.Id != partnerAccount.Id); var reatailerAccount = _olmaPostingAccountRepo.FindAll().IgnoreQueryFilters().FirstOrDefault(a => a.CustomerDivisions.Any(c => c.Customer.Organization.Name.Contains("Lieferant"))); //HACK Hardcoded list of allowed destination accounts var destinationAccounts = new List <AllowedPostingAccount>(); if (reatailerAccount != null) { destinationAccounts.Add(new AllowedPostingAccount() { PostingAccountId = reatailerAccount.Id, DisplayName = $"Konto Lieferant" }); // [Id: {reatailerAccount.Id}]"}); } if (shipperAccount != null) { destinationAccounts.Add(new AllowedPostingAccount() { PostingAccountId = shipperAccount.Id, DisplayName = $"Konto Spedition" }); } if (partnerAccount != null) { destinationAccounts.Add(new AllowedPostingAccount() { PostingAccountId = partnerAccount.Id, DisplayName = $"Konto Partner" }); } return(Ok(destinationAccounts.AsEnumerable())); }