Ejemplo n.º 1
0
        public OperationResult <ProviderFullInformation[]> GetProviders(long clientId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Logger.Trace("Get providers, client id - {0}", clientId);

                var providers = signalServiceRepository.GetProvider(clientId);
                var accsInfo = accService.GetAccountsInfo(providers.Select(information => information.AccountId).ToArray());
                if (!accsInfo.IsSuccess)
                {
                    throw new OperationException(accsInfo.Error, accsInfo.Code);
                }

                foreach (var info in accsInfo.Result)
                {
                    var acc = providers.First(information => information.AccountId == info.AccountId);
                    acc.Balance = (decimal)info.Balance;
                    acc.Equity = (decimal)info.Equity;
                    acc.Leverage = info.Leverage;
                    acc.Profit = (decimal)info.Equity - (decimal)info.Balance;
                    acc.WorkingDays = info.WorkingDays;
                }
                return providers;
            }));
        }