Esempio n. 1
0
    private void SetSelectedPricesList()
    {
        if (!String.IsNullOrEmpty(filter.Prices))
        {
            Int32 f;
            selectedPricesList = filter.Prices.Split(',').Select(i =>
            {
                if (Int32.TryParse(i, out f) && f >= 0 && f < pricesListDataSource.Count)
                {
                    return(f);
                }

                return(-1);
            })
                                 .Where(i => i != -1)
                                 .Distinct()
                                 .ToDictionary(i => i, i => pricesListDataSource.Table.Rows[i] as FlyerMeDS.fly_sp_GetListSizeRow);

            if (view.ShouldSaveSelectedPricesIntoFlyer)
            {
                var flyer = WizardFlyer.GetFlyer();

                if (flyer != null)
                {
                    flyer.SelectedPricesList = PricesList.FromPricesList(selectedPricesList);
                }
            }
        }
        else
        {
            selectedPricesList = new Dictionary <Int32, FlyerMeDS.fly_sp_GetListSizeRow>();
        }
    }
Esempio n. 2
0
        public override ObjectId GenerateId()
        {
            if (!PricesList.Any())
            {
                throw new Exception("Cannot auto-generate an ID for 'MarketPrices' unless it has prices");
            }

            if (PricesList.GroupBy(x => x.Network).Count() > 1)
            {
                throw new Exception("Cannot auto-generate an ID for 'MarketPrices' unless all the prices are from the same network");
            }

            return(GetHash(FirstPrice.Network));
        }
Esempio n. 3
0
        public void Add(MarketPrice price)
        {
            if (price?.Pair == null)
            {
                return;
            }

            if (price.Network == null)
            {
                MissedPairs.Add(price.Pair);
                return;
            }

            if (price.Price > 0)
            {
                PricesList.Add(price);
            }
        }
Esempio n. 4
0
        public MarketPrices AsNormalised()
        {
            var normalised = PricesList.ToList();

            var forNormalisation = normalised.Where(x => !x.Pair.IsNormalised).ToList();

            normalised.RemoveAll(x => forNormalisation.Contains(x));

            foreach (var i in forNormalisation)
            {
                normalised.Add(i.Reversed);
            }

            return(new MarketPrices(normalised)
            {
                IdBacking = IdBacking, UtcCreated = UtcCreated, MissedPairs = new AssetPairs(MissedPairs.Select(x => x.Normalised))
            });
        }