示例#1
0
        public OperationResult CancelInvestmentRequest(Guid requestId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var investmentRequest = context.InvestmentRequests
                                        .Include(x => x.User)
                                        .ThenInclude(x => x.Wallets)
                                        .First(x => x.Id == requestId && x.Status == InvestmentRequestStatus.New);

                investmentRequest.Status = InvestmentRequestStatus.Cancelled;

                if (investmentRequest.Type == InvestmentRequestType.Invest)
                {
                    var investor = investmentRequest.User;
                    var wallet = investor.Wallets.First(x => x.Currency == Currency.GVT);

                    var tx = new WalletTransactions
                    {
                        Id = Guid.NewGuid(),
                        Type = WalletTransactionsType.CancelInvestmentRequest,
                        WalletId = wallet.Id,
                        Amount = investmentRequest.Amount,
                        Date = DateTime.UtcNow,
                        InvestmentProgramtId = investmentRequest.InvestmentProgramtId
                    };

                    context.Add(tx);

                    wallet.Amount += investmentRequest.Amount;
                }

                context.SaveChanges();
            }));
        }
示例#2
0
        public OperationResult <ClosePeriodData> GetClosingPeriodData(Guid investmentProgramId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var program = context.InvestmentPrograms
                              .Include(x => x.Periods)
                              .ThenInclude(x => x.InvestmentRequests)
                              .First(x => x.Id == investmentProgramId);

                var data = new ClosePeriodData
                {
                    CurrentPeriod = program.Periods.FirstOrDefault(x => x.Status == PeriodStatus.InProccess)?.ToPeriod()
                };

                data.CanCloseCurrentPeriod = data.CurrentPeriod != null && data.CurrentPeriod.DateTo <= DateTime.UtcNow;
                data.TokenHolders = context.InvestorTokens
                                    .Where(x => x.ManagerTokenId == program.ManagerTokenId)
                                    .Select(x => new InvestorAmount
                {
                    InvestorId = x.InvestorAccountId,
                    Amount = x.Amount
                })
                                    .ToList();

                return data;
            }));
        }
        public OperationResult <long> InvestorCreateAndInvest(long clientId, long masterId, int walletId, decimal amount, short reinvestPercent)
        {
            Logger.Trace("Check existance and invest");
            return(InvokeOperations.InvokeOperation(() =>
            {
                if (amount < 0)
                {
                    throw new Exception("Amount should be positive");
                }
                var master = repository.GetMaster(masterId);
                if (master.client_account_id == clientId)
                {
                    throw new OperationException("You can't invest to your own account", ResultCode.TrustManagementCantInvestToYourOwnAccount);
                }
                var investor = repository.GetInvestor(clientId, masterId);
                if (investor != null && !investor.isdeleted)
                {
                    throw new OperationException("You already invested to that master", ResultCode.TrustManagementAlreadyInvested);
                }

                return repository.CreateTrustManagementInvestorAccount(clientId, masterId, walletId, amount, reinvestPercent);
                //else
                //{
                //	repository.InvestRequest(investor.id, amount, false);
                //	return new InvestorData();
                //}
            }));
        }
示例#4
0
        public OperationResult UpdateUserProfile(Guid userId, UpdateProfileViewModel profile)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                if (context.Profiles.Any(x => x.UserName == profile.UserName && x.UserId != userId))
                {
                    throw new Exception("Username already exists");
                }

                var user = context.Profiles.First(x => x.UserId == userId);

                user.UserName = profile.UserName;
                user.Avatar = profile.Avatar;
                user.Address = profile.Address;
                if (profile.Birthday.HasValue)
                {
                    user.Birthday = profile.Birthday.Value;
                }
                user.City = profile.City;
                user.Country = profile.Country;
                user.DocumentNumber = profile.DocumentNumber;
                user.DocumentType = profile.DocumentType;
                user.FirstName = profile.FirstName;
                if (profile.Gender.HasValue)
                {
                    user.Gender = profile.Gender.Value;
                }
                user.LastName = profile.LastName;
                user.MiddleName = profile.MiddleName;
                user.Phone = profile.Phone;

                context.SaveChanges();
            }));
        }
示例#5
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;
            }));
        }
示例#6
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;
            }));
        }
        public OperationResult <MasterSettings> GetMasterSettings(long masterId)
        {
            Logger.Trace("Get master settings for {0}", masterId);
            return(InvokeOperations.InvokeOperation(() =>
            {
                var master = repository.GetMaster(masterId);
                //var masterDeposit = repository.GetMasterInvestSum(masterId);
                //var investDeposit = repository.GetInvestSumByMaster(masterId);
                var settings = new MasterSettings
                {
                    NextProcessing = master.date_next_processing,
                    Period = master.period,
                    ManagementFee = master.fee_management,
                    SuccessFee = master.fee_success,
                    MasterAmount = master.amount_own,
                    //InvestorsCount = repository.GetInvestorsCount(masterId),
                    Nickname = master.nickname,
                    //MasterDeposit = masterDeposit,
                    //InvestorsDeposit = investDeposit,
                    MinimalAmount = master.amount_min
                };

                return settings;
            }));
        }
示例#8
0
        public OperationResult RequestForWithdraw(Invest model)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var investor = context.Users
                               .First(x => x.Id == model.UserId);

                var lastPeriod = context.Periods
                                 .Where(x => x.InvestmentProgramId == model.InvestmentProgramId)
                                 .OrderByDescending(x => x.Number)
                                 .First();

                var invRequest = new InvestmentRequests
                {
                    Id = Guid.NewGuid(),
                    UserId = model.UserId,
                    Amount = model.Amount,
                    Date = DateTime.UtcNow,
                    InvestmentProgramtId = model.InvestmentProgramId,
                    Status = InvestmentRequestStatus.New,
                    Type = InvestmentRequestType.Withdrawal,
                    PeriodId = lastPeriod.Id
                };

                context.Add(invRequest);
                context.SaveChanges();
            }));
        }
示例#9
0
        public OperationResult SubscribeByNickname(long slaveId, string masterNickname, SubscriptionSettings settings)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Logger.Trace("Subscribe, slave id - {0}, master nickname - {1}", slaveId, masterNickname);
                var accountInformation = accService.ChangeAccountRole(slaveId, AccountRole.SignalSubscriber);

                if (!accountInformation.IsSuccess)
                {
                    throw new OperationException(accountInformation.Error, accountInformation.Code);
                }
                var statuses = accService.GetAccountStatuses(slaveId);
                if (!statuses.IsSuccess)
                {
                    throw new OperationException(statuses.Error, statuses.Code);
                }
                if (statuses.Result.Has(AccountStatuses.IsPropTrading))
                {
                    throw new OperationException("Not available", ResultCode.SiteOperationNotAvailable);
                }

                signalServiceRepository.SignalSubscription((short)SubscriptionStatus.On, slaveId, masterNickname, settings,
                                                           accountInformation.Result);
            }));
        }
示例#10
0
        public OperationResult <InvestorDashboard> GetInvestorDashboard(Guid investorUserId, Guid?userId, UserType?userType)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var requests = context.InvestmentRequests
                               .Include(x => x.InvestmentProgram)
                               .ThenInclude(x => x.ManagerAccount)
                               .ThenInclude(x => x.ManagersAccountsTrades)
                               .Include(x => x.InvestmentProgram)
                               .ThenInclude(x => x.ManagerAccount)
                               .ThenInclude(x => x.User)
                               .ThenInclude(x => x.Profile)
                               .Include(x => x.InvestmentProgram.Token)
                               .Include(x => x.InvestmentProgram.ManagerAccount.ManagersAccountsStatistics)
                               .Include(x => x.InvestmentProgram.Periods)
                               .Include(x => x.InvestmentProgram.Token)
                               .ThenInclude(x => x.InvestorTokens)
                               .ThenInclude(x => x.InvestorAccount)
                               .Where(x => x.InvestorAccount.UserId == investorUserId)
                               .ToList()
                               .GroupBy(x => x.InvestmentProgram, (program, reqs) => program.ToInvestmentProgramDashboard(userId, userType))
                               .ToList();

                var result = new InvestorDashboard {
                    InvestmentPrograms = requests
                };

                return result;
            }));
        }
示例#11
0
        public OperationResult <List <OrderModel> > ConvertMetaTrader4OrdersFromCsv(string ipfsText)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");

                var csv = ipfsText.Split(Environment.NewLine);
                var header = GetHeaderMap(BrokerTradeServerType.MetaTrader4, csv.First());
                if (!header.IsSuccess)
                {
                    throw new Exception(header.Errors.FirstOrDefault());
                }

                var trades = new List <OrderModel>();
                for (var i = 0; i < csv.Length; i++)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var fields = csv[i].Split(";");
                    var order = new OrderModel();
                    foreach (var headerText in header.Data)
                    {
                        var field = fields[headerText.Value].Replace("\"", "");
                        var propInfo = order.GetType().GetProperty(headerText.Key);
                        dynamic value = null;
                        if (propInfo.PropertyType == typeof(string))
                        {
                            value = field;
                        }
                        else if (propInfo.PropertyType == typeof(decimal))
                        {
                            value = Convert.ToDecimal(field);
                        }
                        else if (propInfo.PropertyType == typeof(int))
                        {
                            value = Convert.ToInt32(field);
                        }
                        else if (propInfo.PropertyType == typeof(long))
                        {
                            value = Convert.ToInt64(field);
                        }
                        else if (propInfo.PropertyType == typeof(DateTime))
                        {
                            value = DateTime.ParseExact(field, "G", null);
                        }
                        else if (propInfo.PropertyType == typeof(TradeDirectionType))
                        {
                            value = Enum.Parse(typeof(TradeDirectionType), field);
                        }

                        propInfo.SetValue(order, value, null);
                    }
                    trades.Add(order);
                }
                return trades;
            }));
        }
示例#12
0
        public OperationResult SaveNewOpenTrade(NewOpenTradesEvent openTradesEvent)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                foreach (var openTrades in openTradesEvent.OpenTrades)
                {
                    var existsTrades = context.ManagersAccountsOpenTrades
                                       .Where(x => x.ManagerAccountId == openTrades.ManagerAccountId)
                                       .ToList();
                    context.RemoveRange(existsTrades);

                    foreach (var trades in openTrades.Trades)
                    {
                        var t = new ManagersAccountsOpenTrades
                        {
                            Id = Guid.NewGuid(),
                            DateUpdateFromTradePlatform = DateTime.UtcNow,
                            ManagerAccountId = openTrades.ManagerAccountId,

                            Ticket = trades.Ticket,
                            Symbol = trades.Symbol,
                            Profit = trades.Price,
                            Price = trades.Price,
                            Direction = trades.Direction,
                            DateOpenOrder = trades.Date,
                            Volume = trades.Volume
                        };
                        context.Add(t);
                    }
                    context.SaveChanges();
                }
            }));
        }
 public OperationResult <InvestSettings> GetInvestSettings(long investorId)
 {
     Logger.Trace("Get invest settings, investor id - {0}", investorId);
     return(InvokeOperations.InvokeOperation(() =>
     {
         var investSettings = repository.GetInvestSettings(investorId);
         var investor = investSettings.Item1;
         var master = investSettings.Item2;
         if (investor.isdeleted || master.isdeleted)
         {
             throw new Exception("Account is deleted");
         }
         var deposit = repository.GetInvestSumByInvestor(investor.id);
         var settings = new InvestSettings
         {
             Reinvest = investor.reinvest_percent,
             Amount = investor.amount,
             MasterId = master.trading_account_id,
             MasterNickname = master.nickname,
             CurrentProfit = 0,
             NextProcessing = master.date_next_processing,
             Period = master.period,
             Deposit = deposit
         };
         return settings;
     }));
 }
示例#14
0
        public OperationResult <UploadResult> Upload(IFormFile uploadedFile, Guid?userId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var fileName = Guid.NewGuid() + (uploadedFile.FileName.Contains(".")
                                   ? uploadedFile.FileName.Substring(uploadedFile.FileName.LastIndexOf(".", StringComparison.Ordinal))
                                   : "");
                using (var stream = new FileStream(Path.Combine(Constants.UploadPath, fileName), FileMode.Create))
                {
                    uploadedFile.CopyTo(stream);
                }

                var file = new Files
                {
                    Id = Guid.NewGuid(),
                    UploadDate = DateTime.UtcNow,
                    UserId = userId,
                    Path = fileName,
                    FileName = uploadedFile.FileName,
                    ContentType = uploadedFile.ContentType
                };
                context.Add(file);
                context.SaveChanges();

                return new UploadResult {
                    Id = file.Id
                };
            }));
        }
示例#15
0
        public OperationResult <WalletInvestmentPrograms> GetInvestmentProgramsWithTx(string mask, Guid userId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var query = context.WalletTransactions
                            .Include(x => x.InvestmentRequest)
                            .ThenInclude(x => x.InvestmentProgram)
                            .Where(x => x.Wallet.UserId == userId && x.InvestmentRequest != null);

                if (!string.IsNullOrEmpty(mask))
                {
                    mask = mask.Trim().ToLower();
                    query = query.Where(x => x.InvestmentRequest.InvestmentProgram.Title.ToLower().Contains(mask));
                }

                var res = query
                          .DistinctBy(x => x.InvestmentRequest.InvestmentProgramtId)
                          .Select(x => new WalletInvestmentProgram
                {
                    Id = x.InvestmentRequest.InvestmentProgram.Id,
                    Title = x.InvestmentRequest.InvestmentProgram.Title
                })
                          .ToList();
                return new WalletInvestmentPrograms {
                    InvestmentPrograms = res
                };
            }));
        }
示例#16
0
        public OperationResult AddProvider(long accountId, string nickname, string description, decimal commission)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Logger.Trace("Add logger, account id - {0}, nickname - {1}", accountId, nickname);

                var accountInformation = accService.GetMt4AccountInfo(accountId);
                if (!accountInformation.IsSuccess)
                {
                    throw new OperationException(accountInformation.Error, accountInformation.Code);
                }
                var statuses = accService.GetAccountStatuses(accountId);
                if (!statuses.IsSuccess)
                {
                    throw new OperationException(statuses.Error, statuses.Code);
                }
                if (statuses.Result.Has(AccountStatuses.IsPropTrading))
                {
                    throw new OperationException("Not available", ResultCode.SiteOperationNotAvailable);
                }

                signalServiceRepository.AddProvider(accountInformation.Result.ClientId,
                                                    accountId,
                                                    nickname,
                                                    true,
                                                    (int)accountInformation.Result.AccountTypeId,
                                                    accountInformation.Result.Login,
                                                    description,
                                                    accountInformation.Result.Avatar,
                                                    accountInformation.Result.Currency,
                                                    commission);

                Logger.Trace("Provider added (account {0})", accountId);
            }));
        }
示例#17
0
        public OperationResult <StatisticsAccount[]> GetProfitStatisticsAccounts(long[] accountsId, DateTime beginDate, DateTime endDate)
        {
            Logger.Trace("Get statistics (profit total) for {1} accounts: {0}", TrimString(string.Join(", ", accountsId)), accountsId.Length);

            return(InvokeOperations.InvokeOperation(() =>
            {
                var statisticsAccounts = statisticRepository.GetStatisticsAccounts(accountsId, beginDate, endDate);

                return statisticsAccounts
                .GroupBy(x => x.account_id)
                .Select(x => new StatisticsAccount
                {
                    AccountId = x.Key,
                    Statistics = x
                                 .Select(s => new Tuple <DateTime, decimal>(s.date, s.closed_profit_total))
                                 .ToArray()
                })
                .Union(accountsId
                       .Where(x => statisticsAccounts.All(s => s.account_id != x))
                       .Select(x => new StatisticsAccount
                {
                    AccountId = x,
                    Statistics = new[] { new Tuple <DateTime, decimal>(DateTime.Now.Date, 0m) }
                }))
                .ToArray();
            }));
        }
        public OperationResult <TradeServerViewModel> GetInitData(Guid tradeServerId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                //var data = context.TradeServers
                //                  .First(x => x.Id == tradeServerId)
                //                  .ToTradeServer();

                var tournament = context.Tournaments
                                 .FirstOrDefault(x => x.IsEnabled && x.DateTo > DateTime.Now)?
                                 .ToTournament();

                var newParticipants = context.Participants
                                      .Where(x => x.TradeAccount == null)
                                      .Select(x => x.ToParticipantRequest())
                                      .ToList();

                var tradeAccounts = context.TradeAccounts
                                    .Where(x => x.TradeServerId == tradeServerId)
                                    .Select(x => x.ToTradeAccount())
                                    .ToList();

                return new TradeServerViewModel
                {
                    Tournament = tournament,
                    ParticipantRequest = newParticipants,
                    TradeAccounts = tradeAccounts
                };
            }));
        }
示例#19
0
 public OperationResult <OrderData[]> GetPeriodHistory(long accountId, DateTime beginDate, DateTime endDate, int skip, int take)
 {
     Logger.Trace("Get history for: {0} , begin date: {1} end date: {2}", accountId, beginDate, endDate);
     return(InvokeOperations.InvokeOperation(() =>
     {
         var accountInfo = accountService.GetMt4AccountInfo(accountId);
         var res = accountInfo.Result;
         if (!accountInfo.IsSuccess)
         {
             Logger.Error("Get trading info error: {0}", accountInfo.Error);
             throw new OperationException(accountInfo.Error, accountInfo.Code);
         }
         return mt4Repositories[res.ServerName]
         .GetAccountPeriodTrades(new[] { res.Login }, beginDate, endDate, skip, take)
         .Select(o => new OrderData
         {
             ClosePrice = Math.Round(o.CLOSE_PRICE, o.DIGITS),
             Login = o.LOGIN,
             CloseTime = o.CLOSE_TIME,
             Cmd = (OrderType)o.CMD,
             Commission = o.COMMISSION,
             Digits = o.DIGITS,
             OpenPrice = Math.Round(o.OPEN_PRICE, o.DIGITS),
             OpenTime = o.OPEN_TIME,
             OrderId = o.TICKET,
             Profit = Math.Round(o.PROFIT, 2),
             Swap = o.SWAPS,
             Symbol = o.SYMBOL,
             Volume = Convert.ToInt32(o.VOLUME),
             RealVolume = o.VOLUME
         })
         .ToArray();
     }));
 }
示例#20
0
        public OperationResult <TournamentActivity[]> GetTournamentActivities(int count)
        {
            Logger.Trace("Get last {0} activities", count);
            return(InvokeOperations.InvokeOperation(() =>
            {
                var accountIds = tournamentRepository.GetVisibleTournamentsAccountIds();

                var activities = statisticService.GetAccountsActivities(count, accountIds);
                if (!activities.IsSuccess)
                {
                    throw new OperationException(activities.Error, activities.Code);
                }

                return activities.Result.Select(x => new TournamentActivity
                {
                    Country = x.Country,
                    Nickname = x.Nickname,
                    OrderType = x.OrderType.ToString(),
                    Price = x.Price,
                    Profit = x.Profit,
                    Symbol = x.Symbol,
                    Time = x.Time,
                    TradingAccountId = x.TradingAccountId
                }).ToArray();
            }));
        }
示例#21
0
        public OperationResult <List <TournamentAccount> > GetAccountsForRound(long clientId, long roundId)
        {
            Logger.Trace("Get client {0} accounts for round id {1}", clientId, roundId);
            return(InvokeOperations.InvokeOperation(() =>
            {
                bool isDemo = tournamentRepository.GetRound(roundId).Tournament.isdemo;

                var accountsData = accountService.GetAccountsInfoByRole(clientId, AccountRole.Tournament);
                if (!accountsData.IsSuccess)
                {
                    throw new Exception(accountsData.Error);
                }

                return accountsData.Result
                .Where(x => isDemo
                                                ? x.AccountType.ToLower().Contains("demo")
                                                : !x.AccountType.ToLower().Contains("demo"))
                .Select(x => new TournamentAccount
                {
                    Id = x.AccountId,
                    ClientAccountId = x.ClientId,
                    Login = x.Login,
                    Avatar = x.Avatar,
                    Nickname = x.Nickname
                })
                .ToList();
            }));
        }
 public OperationResult <int> GetIvestorsCount(long masterId)
 {
     Logger.Trace("Get investors amount for master {0}", masterId);
     return
         (InvokeOperations.InvokeOperation(
              () => repository.GetMasterInvestors(masterId).Count(x => x.status == (short)AccountStatus.In)));
 }
        public OperationResult <MasterData[]> GetMasters(long clientId)
        {
            Logger.Trace("Get master accounts info for client {0}", clientId);
            return(InvokeOperations.InvokeOperation(() =>
            {
                var mastersInfo = repository.GetMasters(clientId);

                foreach (var m in mastersInfo)
                {
                    var masterInvestors = repository.GetMasterInvestors(m.AccountId);
                    m.Investors = masterInvestors.Select(x => new MasterInvestorData
                    {
                        Avatar = x.avatar,
                        ClientId = x.client_account_id,
                        InvestorId = x.id
                    }).ToList();
                    m.InvestorsCount = masterInvestors.Count(x => x.status != (short)AccountStatus.PendingIn);
                    m.InvestorsIncoming = masterInvestors.Count(x => x.status == (short)AccountStatus.PendingIn) -
                                          masterInvestors.Count(x => x.status == (short)AccountStatus.PendingOut);
                    m.Investments += masterInvestors.Sum(x => x.amount);
                    m.InvestmentsIncoming = repository.GetInvestSumByMaster(m.AccountId) +
                                            repository.GetInvestSumByMasterInvestors(m.AccountId);
                }

                return mastersInfo;
            }));
        }
示例#24
0
        public OperationResult <Delivery[]> GetDeliveries(long clientId)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                Logger.Trace("Get deliveries. clientId = {0}", clientId);
                var deliveries = signalServiceRepository.GetDeliveries(clientId);

                var accountInfos = accService.GetAccountsInfo(deliveries.Select(x => (long)x.Provider.id).ToArray());
                if (!accountInfos.IsSuccess)
                {
                    throw new OperationException(accountInfos.Error, accountInfos.Code);
                }

                var deliveriesResults = new List <Delivery>();

                foreach (var accountInfo in accountInfos.Result)
                {
                    var provider = deliveries.FirstOrDefault(x => x.Provider.id == accountInfo.AccountId);
                    if (provider == null)
                    {
                        throw new Exception("Provider not found!");
                    }

                    var deliveryResult = new Delivery
                    {
                        Login = accountInfo.Login,
                        Avatar = accountInfo.Avatar,
                        AccountId = accountInfo.AccountId,
                        AccountType = accountInfo.AccountType,
                        Balance = (decimal)accountInfo.Balance,
                        Commission = provider.Provider.commission ?? 0.0m,
                        Nickname = provider.Provider.nickname,
                        WorkingDays = 0,
                        Procent = 100 + (((decimal)accountInfo.Balance / 100) * (decimal)(accountInfo.Equity - accountInfo.Balance)),
                        Equity = (decimal)accountInfo.Equity,
                        Profit = (decimal)(accountInfo.Equity - accountInfo.Balance),
                        Currency = accountInfo.Currency,
                        Leverage = accountInfo.Leverage,
                        IsVisible = provider.Provider.isvisible,
                        RatingValue = provider.Provider.rating_value,
                        RatingCount = provider.Provider.rating_count,
                        SubscribersCount = deliveries.
                                           Where(x => x.Provider.id == provider.Provider.id && x.Subscription != null).
                                           Select(x => x.Subscription).Count(),

                        Subscribers = new List <AccountConnection>(deliveries.
                                                                   Where(x => x.Provider.id == provider.Provider.id && x.Subscription != null).Select(x => new AccountConnection
                        {
                            AccountId = x.Subscriber.id,
                            Avatar = x.Subscriber.avatar
                        }))
                    };

                    deliveriesResults.Add(deliveryResult);
                }

                return deliveriesResults.ToArray();
            }));
        }
示例#25
0
 public OperationResult <decimal> GetRate(Currency from, Currency to)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         var rate = GetRateAsync(from, to).Result;
         return rate;
     }));
 }
 public OperationResult <string> GetIpfsText(string hash)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         var data = ipfs.FileSystem.ReadAllTextAsync(hash).Result;
         return data;
     }));
 }
 public OperationResult <string> WriteIpfsText(string text)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         var res = ipfs.FileSystem.AddTextAsync(text).Result;
         return res.Id.Hash.ToString();
     }));
 }
示例#28
0
 public OperationResult <Pass[]> GetAllTournamentsPasses()
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         Logger.Trace("Get all tournament passes");
         return tournamentRepository.GetAllTournamentsPasses();
     }));
 }
示例#29
0
 public OperationResult <ClientPass[]> GetClientPasses(long clientId)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         Logger.Trace("Get client {0} passes", clientId);
         return tournamentRepository.GetClientPasses(clientId);
     }));
 }
示例#30
0
 public OperationResult <AccountDayStatistic> GetDayStatistic(long accountId)
 {
     return(InvokeOperations.InvokeOperation(() =>
     {
         Logger.Trace("Get day statistic for account {0}", accountId);
         var res = statisticRepository.GetLastStatistic(accountId);
         return res != null ? new AccountDayStatistic(res) : null;
     }));
 }
示例#31
0
 public ProcessTimeZone(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
示例#32
0
 public ProcessUpdatePattern(InvokeOperations.operations mode)
 {
     this.mode = mode;
 }
 public ProcessSpeedingNotQueries(InvokeOperations.operations mode)
 {
     this.mode = mode;
 }
 public ProcessIconNonQueries(InvokeOperations.operations mode)
 {
     this.mode = mode;
 }
示例#35
0
 public ProcessNewScheme(InvokeOperations.operations mode)
 {
     this.mode = mode;
 }
示例#36
0
 public ProcessRulesData(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
 public ProcessUserGroupUnits(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
 public ProcessUnitTypeNotQueries(InvokeOperations.operations mode)
 {
     this.mode = mode;
 }
示例#39
0
 public ProcessUnitUserWise(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
示例#40
0
 public ProcessContact(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
示例#41
0
 public ProcessUser(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
 public ProcessCompanyNonQueries(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
 public ProcessUnitManagementQueries(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
 public ProcessPatternMaintenance(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }
示例#45
0
 public ProcessSafetyZone(InvokeOperations.operations _mode)
 {
     this._mode = _mode;
 }