Esempio n. 1
0
        public List <WatchlistModel> GetWatchlists()
        {
            try
            {
                var response = _igRestApiClient.listOfWatchlists().RunSync();
                if (response && (response.Response.watchlists != null))
                {
                    var watchlists = new List <WatchlistModel>();

                    foreach (var wl in response.Response.watchlists)
                    {
                        var wm = new WatchlistModel();
                        wm.WatchlistId   = wl.id;
                        wm.WatchlistName = wl.name;
                        wm.Editable      = wl.editable;
                        wm.Deletable     = wl.deleteable;

                        watchlists.Add(wm);
                    }

                    return(watchlists);
                }
            }
            catch (Exception ex)
            {
            }

            return(null);
        }
Esempio n. 2
0
        private dynamic RouteCompare(dynamic items)
        {
            var result    = new List <int>();
            var idsString = (string)items.ids;

            var ids = idsString.Split(',');

            foreach (var id in ids)
            {
                int foundId;
                if (int.TryParse(id, out foundId))
                {
                    result.Add(foundId);
                }
            }

            try
            {
                sql.Open(WebSettings.Settings.CreateDescription());

                DataService db = new DataService(sql);

                var itemList = new List <Item>();

                foreach (var id in result)
                {
                    var itemModel = db.SelectItem(id, true);
                    itemList.Add(itemModel.Item);
                }
                var watchlist = new WatchlistModel();
                watchlist.Items = itemList;

                var statusModel = db.SelectStatus();
                watchlist.Status = statusModel;

                return(View["watchlist", watchlist]);
            }
            catch
            {
                return(Response.AsRedirect("/"));
            }
        }
Esempio n. 3
0
        public List <WatchlistMarketModel> GetWatchlistMarkets(WatchlistModel watchlist)
        {
            try
            {
                var response = _igRestApiClient.instrumentsForWatchlist(watchlist.WatchlistId).RunSync();
                if (response != null)
                {
                    if (response && (response.Response.markets != null) && (response.Response.markets.Count > 0))
                    {
                        var watchlistMarkets = new List <WatchlistMarketModel>();
                        foreach (var wl in response.Response.markets)
                        {
                            var wim = new WatchlistMarketModel();
                            wim.Model                          = new InstrumentModel();
                            wim.Model.High                     = wl.high;
                            wim.Model.Low                      = wl.low;
                            wim.Model.Epic                     = wl.epic;
                            wim.Model.Bid                      = wl.bid;
                            wim.Model.Offer                    = wl.offer;
                            wim.Model.PctChange                = wl.percentageChange;
                            wim.Model.NetChange                = wl.netChange;
                            wim.Model.InstrumentName           = wl.instrumentName;
                            wim.Model.StreamingPricesAvailable = wl.streamingPricesAvailable;
                            wim.Model.MarketStatus             = wl.marketStatus;

                            watchlistMarkets.Add(wim);
                        }

                        return(watchlistMarkets);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(null);
        }