예제 #1
0
        public OperationResult <List <ProviderInfo> > GetProvidersList(long subscriberId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Logger.Debug("Get providers list for {0}", subscriberId);
                var providers = signalServiceRepository.GetProvidersBySubscriber(subscriberId);
                var result = new List <ProviderInfo>();
                var openOrders = accService.GetOpenOrders(subscriberId);
                if (!openOrders.IsSuccess)
                {
                    throw new OperationException(openOrders.Error, openOrders.Code);
                }

                foreach (var signalProvider in providers)
                {
                    var provider = new ProviderInfo
                    {
                        AccountId = signalProvider.id,
                        Nickname = signalProvider.nickname,
                        Avatar = signalProvider.avatar,
                    };
                    foreach (var trade in openOrders.Result)
                    {
                        var providerId = TradeProvider(trade.Comment);
                        if (providerId == provider.AccountId)
                        {
                            provider.Profit += trade.CurrentProfit;
                        }
                    }
                    result.Add(provider);
                }
                return result;
            }));
        }