public OperationResult <SubscriptionData[]> GetProviderSubscribers(long providerId) { return(InvokeOperations.InvokeOperation(() => { Logger.Trace("Get provider subscriptions, provider id - {0}", providerId); var subscriptions = signalServiceRepository.GetProviderSubscriptions(providerId); var accountInfos = accService.GetAccountsInfo(subscriptions.Select(x => (long)x.Subscriber.id).Distinct().ToArray()); if (!accountInfos.IsSuccess) { throw new OperationException(accountInfos.Error, accountInfos.Code); } var subscriptionsResult = new List <SubscriptionData>(); foreach (var accountInfo in accountInfos.Result) { var info = accountInfo; var subscription = subscriptions.First(x => x.Subscriber.id == info.AccountId); var subscriptionResult = new SubscriptionData { Login = accountInfo.Login, ClientId = subscription.Subscriber.client_account_id, Avatar = accountInfo.Avatar, AccountId = accountInfo.AccountId, AccountType = accountInfo.AccountType, Balance = (decimal)accountInfo.Balance, Nickname = subscription.Subscriber.nickname, ProviderNickname = subscription.Provider.nickname, Equity = (decimal)accountInfo.Equity, WorkingDays = info.WorkingDays, Leverage = accountInfo.Leverage, Currency = accountInfo.Currency, Profit = subscription.Subscription.slave_profit, Procent = 100 + (((decimal)accountInfo.Balance / 100) * (decimal)(accountInfo.Equity - accountInfo.Balance)) }; subscriptionsResult.Add(subscriptionResult); } return subscriptionsResult.ToArray(); })); }