public ActionResult SetFilterTeam(TradesViewModel model) { Team selectedTeam = model.Teams.Where(t => t.TeamId == model.SelectedTeamId).FirstOrDefault(); if (model.TeamSelectorMode == "TheirTeam") { model.TheirTeam = selectedTeam; model.TheirFilters = new List <TradeFilterViewModel>(new TradeFilterViewModel[4]); } else if (model.TeamSelectorMode == "MyTeam") { model.MyTeam = selectedTeam; model.MyFilters = new List <TradeFilterViewModel>(new TradeFilterViewModel[4]); if (model.TheirTeam != null && model.MyTeam.TeamId == model.TheirTeam.TeamId) { model.TheirTeam = null; } } model.TeamSelectorMode = null; model.SelectedTeamId = 0; ModelState.Clear(); return(PartialView("TradeFilter", model)); }
public async Task <ActionResult> Trades(TradesViewModel model) { List <TradeRequestViewModel> trades = await tradeService.GetTrades(model.FirstDate, model.SecondDate); model = new TradesViewModel(trades); return(View(model)); }
public SentimentViewModel(ExchangeBase exchangeBase, TradesViewModel tradesViewModel) : base(exchangeBase) { TradesViewModel = tradesViewModel; TradesViewModel.UpdateEvent += TradesViewModelOnUpdateEvent; }
public ActionResult ShowTeamSelectorList(TradesViewModel model) { Team selectedTeam = model.Teams .Where(t => t.TeamId == model.SelectedTeamId) .FirstOrDefault(); List <Team> teams = new List <Team>(model.Teams); if (model.TeamSelectorMode == "TheirTeam") { if (model.MyTeam != null) { int indexToRemove = 0; for (int i = 0; i < teams.Count; i++) { if (teams[i].TeamId == model.MyTeam.TeamId) { indexToRemove = i; } } teams.RemoveAt(indexToRemove); } teams.Insert(0, new Team() { TeamId = 0, Name = "All Teams" }); } return(PartialView("TeamList", teams)); }
public ActionResult ChangePage(TradesViewModel model) { List <Trade> trades = (List <Trade>)Session["Trades"]; model.Trades = trades; return(PartialView("TradeList", model)); }
public async Task <ActionResult> Trades() { List <TradeRequestViewModel> trades = await tradeService.AllTrades(); TradesViewModel model = new TradesViewModel(trades); return(View(model)); }
public ActionResult Edit(TradesViewModel model) { if (ModelState.IsValid) { this.Edit<Trade>(model); return RedirectToAction("Index"); } return this.View(model); }
public ActionResult League(int id) { LeagueManager leagueManager = new LeagueManager(_context); PlayerManager playerManager = new PlayerManager(_context); TradeManager tradeManager = new TradeManager(_context); League league = leagueManager.Get(id); //try get players from session List <Player> players = (List <Player>)Session["Players"]; //try get players from json file if (players == null) { players = JsonConvert.DeserializeObject <List <Player> >(System.IO.File.ReadAllText(@"C:\Users\Collin\Source\Repos\fftoolkit\fftoolkit.Logic\Json Data\players.json")); } //scrape players if (players == null) { players = playerManager.Get(league); players = tradeManager.GetTradeValues(players, league); Session["Players"] = players; } //build teams with players //try get teams from session List <Team> teams = (List <Team>)Session["TeamsWithPlayers"]; //try get teams from json file if (teams == null) { teams = JsonConvert.DeserializeObject <List <Team> >(System.IO.File.ReadAllText(@"C:\Users\Collin\Source\Repos\fftoolkit\fftoolkit.Logic\Json Data\teams.json")); } //scrape teams if (teams == null) { teams = tradeManager.GetTeamsWithPlayers(players, league); Session["TeamsWithPlayers"] = teams; } TradesViewModel model = new TradesViewModel(teams) { League = league }; return(View(model)); }
public IActionResult Trades(DateTimeOffset id) { var coreService = Application.Resolve <ICoreService>(); var model = new TradesViewModel() { InstanceName = coreService.Config.InstanceName, Version = coreService.Version, TimezoneOffset = coreService.Config.TimezoneOffset, Date = id, Trades = GetTrades(id).Values.FirstOrDefault() ?? new List <TradeResult>() }; return(View(model)); }
public ExchangeViewModel(MainViewModel mainViewModel, ExchangeBase exchangeBase) : base(exchangeBase) { Pairs = new PairManageViewModel(exchangeBase); this.MainViewModel = mainViewModel; this.Header = Exchange.Name; //this.Foreground = Brushes.DodgerBlue; MainViewModel.TimerSeconds.Tick += TimerSecondsOnTick; Orders = new UserOrdersViewModel(Exchange); Ticker = new TickerViewModel(Exchange); OrderBook = new OrderBookViewModel(Exchange); Trades = new TradesViewModel(MainViewModel, this, Exchange); Balance = new BalanceViewModel(Exchange); NewBuyOrder = new NewOrderViewModel(Exchange) { Side = OrderSide.Buy }; NewSellOrder = new NewOrderViewModel(Exchange) { Side = OrderSide.Sell }; if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { UpdatePair(); //Exchange.ExchangeManager.Settings. MainViewModel.SettingsService.SettingsLoaded += SettingsServiceOnSettingsLoaded; Pairs.PairChanged += PairsOnPairChanged; OrderBook.Ticker.LastTradeClickEvent += TickerOnLastTradeClickEvent; OrderBook.SelectedAskChanged += OrderBookOnSelectedAskChanged; OrderBook.SelectedBidChanged += OrderBookOnSelectedBidChanged; Balance.SelectedBalanceChanged += BalanceOnSelectedBalanceChanged; CreateTimer(); UpdateViewModels(); RegisterUpdates(); Ticker.Dispatched += TickerOnDispatched; } }
public async Task <IActionResult> Index(DateTimeOffset?id) { TradesViewModel trades = await BotClient.Trading.GetTrades(id ?? DateTimeOffset.Now, CancellationToken.None); return(this.View(trades)); }
public ActionResult FindTrades(TradesViewModel model) { if (model.MyTeam == null) { return(View(model)); } Team myTeam = (Team)Session["MyTeam"]; Team theirTeam = (Team)Session["TheirTeam"]; //if teams have changed, clear trades from session //else, get trades from session List <Trade> trades = null; if ((myTeam != null && !myTeam.Equals(model.MyTeam)) || (theirTeam != null && model.TheirTeam != null && !theirTeam.Equals(model.TheirTeam))) { Session["Trades"] = null; } else { trades = (List <Trade>)Session["Trades"]; } Session["MyTeam"] = model.MyTeam; Session["TheirTeam"] = model.TheirTeam; //if no applicable trades in session, find trades if (trades == null) { TradeManager tradeManager = new TradeManager(_context); trades = new List <Trade>(); if (model.TheirTeam != null) { //find trades with their team List <Trade> teamTrades = tradeManager.FindTrades(model.MyTeam, model.TheirTeam, model.League); trades.AddRange(teamTrades); } else { //find trades with all teams Parallel.ForEach(model.Teams, otherTeam => { if (model.MyTeam.TeamId != otherTeam.TeamId) { trades.AddRange(tradeManager.FindTrades(model.MyTeam, otherTeam, model.League)); } }); } //order trades by those most valuable to both trades = trades .OrderByDescending(t => t.MyTradeSide.Difference * t.TheirTradeSide.Difference) .ToList(); //store teams and trades in session Session["Trades"] = trades; } model.Trades = trades; return(PartialView("TradeList", model)); }