public static string GetCustomerClubDisplayPrice(this List<VariationContent> variations, IMarket market = null)
 {
     var priceAndMarket = GetCustomerClubPrice(variations, market);
     if (priceAndMarket != null)
         return priceAndMarket.Price;
     return string.Empty;
 }
 public virtual ShippingRate GetRate(IShipment shipment, ShippingMethodInfoModel shippingMethodInfoModel, IMarket currentMarket)
 {
     var type = Type.GetType(shippingMethodInfoModel.ClassName);
     var shippingGateway = (IShippingGateway)Activator.CreateInstance(type, currentMarket);
     string message = null;
     return shippingGateway.GetRate(shippingMethodInfoModel.MethodId, (Shipment)shipment, ref message);
 }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="huobi"></param>
		/// <param name="market"></param>
		/// <param name="renderer"></param>
        public AlgoBase(IMarket huobi, HuobiMarket market, Rendering renderer)
		{
			m_huobi = huobi;
			m_market = market;
			m_lastOpenOrders = m_huobi.GetOpenOrders(m_market);
			m_startInfo = m_huobi.GetAccountInfo();
			m_renderer = renderer;
		}
示例#4
0
 public ModuleContext(DateTime time, Location2 location, ITransferManager transferManager, IMarket market, IItemStore itemStore)
 {
     Time = time;
     Location = location;
     TransferManager = transferManager;
     Market = market;
     ItemStore = itemStore;
 }
示例#5
0
        /// <summary>Creates a new instance of Bitstamp API .NET's client service.</summary>
        /// <param name="publicApiKey">Your public API key.</param>
        /// <param name="privateApiKey">Your private API key.</param>
        private BitstampClient(string publicApiKey, string privateApiKey)
        {
            var apiWebClient = new ApiWebClient(Utilities.ApiUrlHttpsBase);

            //Authenticator = new Authenticator(apiWebClient, publicApiKey, privateApiKey);

            Market = new Market(apiWebClient);
        }
        private Money?GetDiscountPrice(IPriceValue defaultPrice, IMarket market, Currency currency)
        {
            if (defaultPrice == null)
            {
                return(null);
            }

            return(_promotionService.GetDiscountPrice(defaultPrice.CatalogKey, market.MarketId, currency).UnitPrice);
        }
        /// <summary>
        /// Intial System consists of:
        /// Three user: daniel with $120, jennie with $100, tom with $80
        /// Private Recipes: daniel has 2, jennie has 1, tom has 1 purchased from the market
        /// Public reicpes: daniel has 1 with price of 20, with review from tom
        /// </summary>
        public void InitializeSystem()
        {
            var userDaniel = DomainObjectsGenerator.GenerateRandoMoneyAccount("daniel");
            var userJennie = DomainObjectsGenerator.GenerateRandoMoneyAccount("jennie");
            var userTom = DomainObjectsGenerator.GenerateRandoMoneyAccount("tom");

            var recipeDaniel1 = DomainObjectsGenerator.GenerateRandomPrivateRecipe(4, userDaniel.UserId);
            var recipeDaniel2 = DomainObjectsGenerator.GenerateRandomPrivateRecipe(2, userDaniel.UserId);
            var recipeJennie1 = DomainObjectsGenerator.GenerateRandomPrivateRecipe(5, userJennie.UserId);

            var recipeOnMarket = PublicRecipe.ConvertFromPrivateRecipe(recipeDaniel1);
            recipeOnMarket.Id = GetRandomInt();
            if (recipeOnMarket.Items != null)
            {
                foreach (var recipeItem in recipeOnMarket.Items)
                {
                    recipeItem.Id = GetRandomInt();
                }
            }
            recipeOnMarket.Price = 20;
            recipeOnMarket.TimePublished = new DateTime(2016, 3, 20, 11, 0, 0);

            var tomsReview = DomainObjectsGenerator.GenerateRandomReview(recipeOnMarket);
            tomsReview.ReviewerUserId = userTom.UserId;
            tomsReview.Comment = "Good recipe";
            tomsReview.Rating = 4;
            recipeOnMarket.AddReview(tomsReview);

            _moneyAccounts = new List<MoneyAccount>
            {
                userDaniel,
                userJennie,
                userTom
            };

            _marketRecipes = new List<PublicRecipe>
            {
                recipeOnMarket
            };

            _moneyAccountRepository = new MoneyAccountRepository(_moneyAccounts);
            _publicRecipeRepository = new PublicRecipeRepository(_marketRecipes);

            _market = new Market(_publicRecipeRepository, _moneyAccountRepository);

            var recipeTom = _market.Purchase(recipeOnMarket.Id, "tom");
            recipeTom.PurchaseInformation.TimePurchased = new DateTime(2016, 4, 1, 9, 0, 0);

            _userRecipes = new List<PrivateRecipe>
            {
                recipeDaniel1,
                recipeDaniel2,
                recipeJennie1,
                recipeTom
            };
            _privateRecipeRepository = new PrivateRecipeRepository(_userRecipes);
        }
示例#8
0
        protected PaymentStep(IPayment payment, IMarket market, ISwedbankPayClientFactory swedbankPayClientFactory)
        {
            MarketId      = market.MarketId;
            PaymentMethod = PaymentManager.GetPaymentMethod(payment.PaymentMethodId);

            if (PaymentMethod != null)
            {
                SwedbankPayClient = swedbankPayClientFactory.Create(PaymentMethod, market.MarketId);
            }
        }
        private IEnumerable <ShippingMethodDto.ShippingMethodRow> GetShipmentMethods()
        {
            IMarket market = _currentMarket.GetCurrentMarket();
            var     str    = market.DefaultLanguage.TwoLetterISOLanguageName;

            return(new List <ShippingMethodDto.ShippingMethodRow>(
                       ShippingManager
                       .GetShippingMethodsByMarket(market.MarketId.Value, false)
                       .ShippingMethod));
        }
 public ConfirmChangeWindow(IMarket m, IOrder order, MainWindowClient windowClient, string message1, string message2, string caption)
 {
     InitializeComponent();
     _market       = m;
     _order        = order;
     _message1     = message1;
     _message2     = message2;
     _caption      = caption;
     _windowClient = windowClient;
 }
示例#11
0
        public virtual ShippingRate GetRate(IShipment shipment, ShippingMethodInfoModel shippingMethodInfoModel,
                                            IMarket currentMarket)
        {
            var    type            = Type.GetType(shippingMethodInfoModel.ClassName);
            var    shippingGateway = (IShippingGateway)Activator.CreateInstance(type);
            string message         = null;

            return(shippingGateway.GetRate(currentMarket, shippingMethodInfoModel.MethodId, (Shipment)shipment,
                                           ref message));
        }
示例#12
0
        protected override Money CalculateSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice)
        {
            IEnumerable <ITaxValue> taxValues = GetTaxValues(lineItem, market, shippingAddress);

            if (!taxValues.Any())
            {
                return(new Money(decimal.Zero, basePrice.Currency));
            }
            return(CalculateLineItemSalesTax(lineItem, market, basePrice, taxValues));
        }
示例#13
0
        private IEnumerable <ShippingRate> GetShippingRates(IMarket market, Currency currency, IShipment shipment)
        {
            var methods         = _shippingManagerFacade.GetShippingMethodsByMarket(market.MarketId.Value, false);
            var currentLanguage = _languageService.GetCurrentLanguage().TwoLetterISOLanguageName;

            return(methods.Where(shippingMethodRow => currentLanguage.Equals(shippingMethodRow.LanguageId, StringComparison.OrdinalIgnoreCase) &&
                                 string.Equals(currency, shippingMethodRow.Currency, StringComparison.OrdinalIgnoreCase))
                   .OrderBy(shippingMethodRow => shippingMethodRow.Ordering)
                   .Select(shippingMethodRow => _shippingManagerFacade.GetRate(shipment, shippingMethodRow, market)));
        }
示例#14
0
        public Economy(
            IMarket market,
            ITradersCollectionFactory tradersCollectionFactory)
        {
            Contract.Requires<ArgumentNullException>(market != null);
            Contract.Requires<ArgumentNullException>(tradersCollectionFactory != null);

            Market = market;
            Traders = tradersCollectionFactory.Create(this, _traders);
        }
示例#15
0
        protected void InsertParameters(IDbCommand cmd, IMarket m)
        {
            SqlParameter n  = new SqlParameter("@name", m.name);
            SqlParameter id = new SqlParameter("@id", m.code);
            SqlParameter d  = new SqlParameter("@desc", m.description);

            cmd.Parameters.Add(n);
            cmd.Parameters.Add(id);
            cmd.Parameters.Add(d);
        }
示例#16
0
        private void DeleteMarket()
        {
            Console.WriteLine("DeleteMarket()");
            Console.WriteLine();
            Console.WriteLine("Insert a code:");
            IMarket market = context.Markets.Find(Int32.Parse(Console.ReadLine()));

            context.DeleteMarket(market);
            Console.WriteLine("Market deleted sucessfully");
        }
        private IEnumerable <ShippingMethodViewModel> CreateShippingMethodViewModels(IMarket market, Currency currency, IShipment shipment)
        {
            var shippingRates = GetShippingRates(market, currency, shipment);

            return(shippingRates.Any()
                ? shippingRates.Select(r => new ShippingMethodViewModel {
                Id = r.Id, DisplayName = r.Name, Price = r.Money
            })
                : Enumerable.Empty <ShippingMethodViewModel>());
        }
 public void Subscribe(IMarket market)
 {
     var internalMarket = this.marketsInvolved.First(m => m == market);
     
     var onInstrumentMarketDataUpdated = this.InstrumentMarketDataUpdated;
     if (onInstrumentMarketDataUpdated != null)
     {
         onInstrumentMarketDataUpdated(this, new MarketDataUpdateDto(market, internalMarket.SellPrice, internalMarket.SellQuantity));
     }
 }
        private IPriceValue GetDefaultPrice(MyVariantion variation, IMarket market, Currency currency)
        {
            var _priceService = ServiceLocator.Current.GetInstance <IPriceService>();

            return(_priceService.GetDefaultPrice(
                       market.MarketId,
                       DateTime.Now,
                       new CatalogKey(AppContext.Current.ApplicationId, variation.Code),
                       currency));
        }
示例#20
0
        internal void RefreshTotalAmount(FXMarket fXMarket, AssetMarket assetMarket)
        {
            IMarket iMkt = fXMarket;

            if (!Ccy.IsCcy())
            {
                iMkt = assetMarket;
            }
            _TotalAmount = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_TotalCcy));
        }
示例#21
0
        private CheckoutOrderData GetCheckoutOrderData(
            ICart cart, IMarket market, PaymentMethodDto paymentMethodDto)
        {
            var totals        = _orderGroupCalculator.GetOrderGroupTotals(cart);
            var shipment      = cart.GetFirstShipment();
            var marketCountry = CountryCodeHelper.GetTwoLetterCountryCode(market.Countries.FirstOrDefault());

            if (string.IsNullOrWhiteSpace(marketCountry))
            {
                throw new ConfigurationException($"Please select a country in CM for market {cart.MarketId}");
            }
            var checkoutConfiguration = GetCheckoutConfiguration(market);

            var orderData = new PatchedCheckoutOrderData
            {
                PurchaseCountry  = marketCountry,
                PurchaseCurrency = cart.Currency.CurrencyCode,
                Locale           = ContentLanguage.PreferredCulture.Name,
                // Non-negative, minor units. Total amount of the order, including tax and any discounts.
                OrderAmount = AmountHelper.GetAmount(totals.Total),
                // Non-negative, minor units. The total tax amount of the order.
                OrderTaxAmount = AmountHelper.GetAmount(totals.TaxTotal),
                MerchantUrls   = GetMerchantUrls(cart),
                OrderLines     = GetOrderLines(cart, totals, checkoutConfiguration.SendProductAndImageUrl)
            };

            if (checkoutConfiguration.SendShippingCountries)
            {
                orderData.ShippingCountries = GetCountries().ToList();
            }

            // KCO_6 Setting to let the user select shipping options in the iframe
            if (checkoutConfiguration.SendShippingOptionsPriorAddresses)
            {
                if (checkoutConfiguration.ShippingOptionsInIFrame)
                {
                    orderData.ShippingOptions = GetShippingOptions(cart, cart.Currency, ContentLanguage.PreferredCulture);
                }
                else
                {
                    if (shipment != null)
                    {
                        orderData.SelectedShippingOption = ShippingManager.GetShippingMethod(shipment.ShippingMethodId)
                                                           ?.ShippingMethod?.FirstOrDefault()
                                                           ?.ToShippingOption();
                    }
                }
            }

            if (paymentMethodDto != null)
            {
                orderData.Options = GetOptions(cart.MarketId);
            }
            return(orderData);
        }
示例#22
0
        private Money GetDiscountPrice(VariationContent variation, IMarket market, Currency currency, Money originalPrice)
        {
            var discountedPrice = _promotionService.GetDiscountPrice(new CatalogKey(_appContext.ApplicationId, variation.Code), market.MarketId, currency);

            if (discountedPrice != null)
            {
                return(discountedPrice.UnitPrice);
            }

            return(originalPrice);
        }
示例#23
0
        public Money GetTaxTotal(IOrderForm orderForm, IMarket market, Currency currency)
        {
            var formTaxes = 0m;

            //calculate tax for each shipment
            foreach (var shipment in orderForm.Shipments.Where(x => x.ShippingAddress != null))
            {
                var shippingTaxes = new List <ITaxValue>();
                foreach (var item in shipment.LineItems)
                {
                    //get the variation entry that the item is associated with
                    var reference = _referenceConverter.GetContentLink(item.Code);
                    var entry     = _contentRepository.Get <VariationContent>(reference);
                    if (entry == null || !entry.TaxCategoryId.HasValue)
                    {
                        continue;
                    }

                    //get the tax values applicable for the entry. If not taxes found then continue with next line item.
                    var taxCategory = CatalogTaxManager.GetTaxCategoryNameById(entry.TaxCategoryId.Value);
                    var taxes       = GetTaxValues(taxCategory, market.DefaultLanguage.Name, shipment.ShippingAddress).ToList();
                    if (taxes.Count <= 0)
                    {
                        continue;
                    }

                    //calculate the line item price, excluding tax
                    var lineItem = (LineItem)item;
                    var lineItemPricesExcludingTax = item.PlacedPrice - (lineItem.OrderLevelDiscountAmount + lineItem.LineItemDiscountAmount) / item.Quantity;
                    var quantity = 0m;

                    if (orderForm.Name.Equals(OrderForm.ReturnName))
                    {
                        quantity = item.ReturnQuantity;
                    }
                    else
                    {
                        quantity = item.Quantity;
                    }

                    formTaxes += taxes.Where(x => x.TaxType == TaxType.SalesTax).Sum(x => lineItemPricesExcludingTax * (decimal)x.Percentage * 0.01m) * quantity;

                    //add shipping taxes for later tax calculation
                    shippingTaxes.AddRange(
                        taxes.Where(x => x.TaxType == TaxType.ShippingTax &&
                                    !shippingTaxes.Any(y => y.Name.Equals(x.Name))));
                }

                //sum the calculated tax for each shipment
                formTaxes += CalculateShippingTax(shippingTaxes, shipment, market, currency);
            }

            return(new Money(currency.Round(formTaxes), currency));
        }
示例#24
0
 public UserService(string userId, IMarket market, 
     IPrivateRecipeRepository privateRecipeRepo, 
     IPublicRecipeRepository publicRecipeRepo, 
     IMoneyAccountRepository moneyAccountRepo)
 {
     UserId = userId;
     _market = market;
     _privateRecipeRepo = privateRecipeRepo;
     _publicRecipeRepo = publicRecipeRepo;
     _moneyAccountRepo = moneyAccountRepo;
 }
示例#25
0
        // new method for the...
        // \Infrastructure\Promotions\CustomPromotionEngineContentLoader.cs
        public IPriceValue GetSalePrice(EntryContentBase entry, decimal quantity)
        {
            // some basic validation
            if (entry == null)
            {
                throw new NullReferenceException("entry object can't be null");
            }

            if (entry as IPricing == null)
            {
                throw new InvalidCastException("entry object must implement IPricing");
            }

            // Need the pricing context...
            // Get the groups
            List <CustomerPricing> customerPricing = GetCustomerPricingList();

            IMarket theMarket = _currentMarket.GetCurrentMarket();

            IEnumerable <Currency> currencies = theMarket.Currencies;

            PriceFilter filter = new PriceFilter()
            {
                Quantity              = quantity,
                Currencies            = currencies,
                CustomerPricing       = customerPricing,
                ReturnCustomerPricing = false
            };

            CatalogKey catalogKey = new CatalogKey(entry.Code); // 3 overloads

            //_pricingLoader.Service.GetPrices(entryLink,theMarket.MarketId.Value)
            IEnumerable <IPriceValue> prices = _priceService.GetPrices(
                theMarket.MarketId.Value, FrameworkContext.Current.CurrentDateTime, catalogKey, filter);

            #region Old garbage

            // Prob. don't want the "BasePrice" ... this is the "SalePrice"
            //return prices.Where(x =>
            //    x.CustomerPricing.PriceTypeId != (CustomerPricing.PriceType)3)
            //    .OrderBy(pv => pv.UnitPrice).FirstOrDefault(); // Lowest price

            #endregion

            // doing for promos
            if (prices.Count() >= 1)
            {
                return(prices.OrderBy(p => p.UnitPrice.Amount).First()); //...
            }
            else
            {
                return(new PriceValue());
            }
        }
        public ProductListViewModel(ProductBase content, 
            IMarket currentMarket,
            CustomerContact currentContact)
            : this()
        {
            ImageUrl = content.GetDefaultImage();
            IsVariation = false;
            AllImageUrls = content.AssetUrls();

            PopulateCommonData(content, currentMarket, currentContact);
        }
示例#27
0
        private Money GetDiscountPrice(EntryContentBase entry, IMarket market, Currency currency, Money originalPrice)
        {
            var discountedPrice = _promotionService.GetDiscountPrice(new CatalogKey(entry.Code), market.MarketId, currency);

            if (discountedPrice != null)
            {
                return(discountedPrice.UnitPrice);
            }

            return(originalPrice);
        }
示例#28
0
        public Analyzer(IMarket market)
        {
            _market = market;
            var periods = new[] { 5, 10, 20, 30, 50, 80, 100 };

            emas = new EMAIndicator[periods.Length];
            for (int i = 0; i < emas.Length; i++)
            {
                emas[i] = new EMAIndicator((uint)periods[i]);
            }
        }
示例#29
0
        internal void RecalculateConvertedAmount(Currency ccy, FXMarket mkt, AssetMarket aMkt)
        {
            _ConvertedCcy = ccy;
            IMarket iMkt = mkt;

            if (!_Ccy.IsCcy())
            {
                iMkt = aMkt;
            }
            _ConvertedAmount = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_ConvertedCcy));
        }
        public string GetScript()
        {
            ICurrentMarket currentMarket = ServiceLocator.Current.GetInstance <ICurrentMarket>();
            IMarket        market        = currentMarket.GetCurrentMarket();


            string script = "ga('require', 'ec');\n";

            script = script + string.Format("ga('set', '&cu', '{0}');", market.DefaultCurrency);
            return(script);
        }
        public ProductListViewModel(ProductBase content,
                                    IMarket currentMarket,
                                    CustomerContact currentContact)
            : this()
        {
            ImageUrl     = content.GetDefaultImage();
            IsVariation  = false;
            AllImageUrls = content.AssetUrls();

            PopulateCommonData(content, currentMarket, currentContact);
        }
示例#32
0
        public void ModifyCcy(FXMarket mkt, AssetMarket aMkt, string v, ICcyAsset valueCcy, bool isLastRow)
        {
            _Ccy = valueCcy;
            IMarket iMkt = mkt;

            if (!_Ccy.IsCcy())
            {
                iMkt = aMkt;
            }
            _ConvertedAmount = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_ConvertedCcy));
            _TotalAmount     = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_TotalCcy));
        }
示例#33
0
 public IMarket Create(IMarket market)
 {
     using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
     {
         mapperHelper.Create(market,
                             (cmd, market) => InsertParameters(cmd, market),
                             "INSERT INTO Market (code, description, name) VALUES(@id,@desc,@name)"
                             );
         ts.Complete();
         return(market);
     }
 }
示例#34
0
        public Strategy(IMarket market)
        {
            Market    = market;
            isStopped = true;

            timer         = new Timer(TimerCallback);
            Interval      = TimeSpan.MaxValue;
            DataStartTime = DateTime.Now.AddMinutes(60 * 24 * 9 * -1);
            lastDataTimes = new Dictionary <string, DateTime>();

            Charts = new Dictionary <string, List <Chart> >();
        }
        public ProductListViewModel Populate(IMarket market)
        {
            ProductListViewModel productListViewModel = new ProductListViewModel(this, market, CustomerContext.Current.CurrentContact)
            {
                PriceString = this.GetDisplayPrice(market),
                BrandName   = Facet_Brand,
                Country     = Country
            };

            productListViewModel.PriceAmount = this.GetDefaultPriceAmount(market);
            return(productListViewModel);
        }
示例#36
0
 public static OrderLine GetOrderLineWithTax(this ILineItem lineItem, IMarket market, IShipment shipment, Currency currency, bool includeProductAndImageUrl = false)
 {
     (int unitPrice, int taxRate, int totalDiscountAmount, int totalAmount, int totalTaxAmount) = GetPrices(lineItem, market, shipment, currency);
     return(GetOrderLine(
                lineItem,
                includeProductAndImageUrl,
                unitPrice,
                totalAmount,
                totalDiscountAmount,
                totalTaxAmount,
                taxRate));
 }
示例#37
0
 public OpenTradeCommand(IPlayer player, IMarket market, ITrade trade)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (market == null)
         throw new ArgumentNullException(nameof(market));
     if (trade == null)
         throw new ArgumentNullException(nameof(trade));
     Player = player;
     this.market = market;
     this.trade = trade;
 }
示例#38
0
        public void ModifyAmount(FXMarket mkt, AssetMarket aMkt, string v, object valueAmount)
        {
            _Amount = Convert.ToDouble(valueAmount);
            IMarket iMkt = mkt;

            if (!_Ccy.IsCcy())
            {
                iMkt = aMkt;
            }
            _ConvertedAmount = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_ConvertedCcy));
            _TotalAmount     = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_TotalCcy));
        }
示例#39
0
        //////////////////////////////////////////////////////////////////////////////////
        //行情测试
        static void MarketTest()
        {
            //创建 IMarket
            // char* path 指 xxx.exe 同级子目录中的 xxx.dll 文件
            int err = -1;

            market = ITradeApi.XFinApi_CreateMarketApi("XTA_W32/Api/XTP_v1.1.18.13_20180516/XFinApi.XTPTradeApi.dll", out err);


            if (err > 0 || market == null)
            {
                Console.WriteLine(string.Format("* Market XFinApiCreateError={0};", StrCreateErrors[err]));
                return;
            }

            //注册事件
            marketEvent = new MarketEvent();
            market.SetListener(marketEvent);

            //连接服务器
            OpenParams openParams = new OpenParams();

            openParams.HostAddress = Cfg.MarketAddress;
            openParams.UserID      = Cfg.UserName;
            openParams.Password    = Cfg.Password;
            openParams.Configs.Add("AuthCode", Cfg.AuthCode);
            openParams.Configs.Add("ClientID", Cfg.ClientID);//可选
            openParams.IsUTF8 = true;
            market.Open(openParams);

            /*
             * 连接成功后才能执行订阅行情等操作,检测方法有两种:
             * 1、IMarket.IsOpened()=true
             * 2、MarketListener.OnNotify中
             * (int)XFinApi.TradeApi.ActionKind.Open == notifyParams.ActionType &&
             * (int)ResultKind.Success == notifyParams.ResultType
             */

            /* 行情相关方法
             * while (!market.IsOpened())
             *   Thread.Sleep(1000);
             *
             * //订阅行情,已在MarketEvent.OnNotify中订阅
             * XFinApi.QueryParams param = new XFinApi.QueryParams();
             * param.ExchangeID = Cfg.ExchangeID;
             * param.InstrumentID = Cfg.InstrumentID;
             * market.Subscribe(param);
             *
             * //取消订阅行情
             * market.Unsubscribe(param);
             */
        }
        // use this one to get shipping taxes in a custom fashion
        protected override Money CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency)
        {
            bool doCustom = true;

            if (!doCustom)
            {
                return(new Money(0, currency));
            }
            else
            {
                return(base.CalculateShippingTaxTotal(shipment, market, currency));
            }
        }
示例#41
0
        public Agent(string type, IMarket market)
        {
            this.Type         = type;
            this.Market       = market;
            this.Behaviors    = new List <AgentBehavior>();
            this.Inventory    = new Inventory();
            this.PriceBeliefs = new PriceBeliefs();
            this.CostBeliefs  = new CostBeliefs(this.PriceBeliefs);

            this.offers = new List <Offer>();

            this.PriceBeliefs.Initialize(market);
        }
 public PropertyChangeNotificationTests()
 {
     _storeName = "PropertyChangeNotificationTests_" + DateTime.UtcNow.Ticks;
     _context = new MyEntityContext("type=embedded;storesDirectory=c:\\brightstar;storeName="+_storeName);
     _ftse = _context.Markets.Create();
     _nyse = _context.Markets.Create();
     _company = _context.Companies.Create();
     _company.Name = "Glaxo";
     _company.HeadCount = 20000;
     _company.PropertyChanged += HandlePropertyChanged;
     _person = _context.FoafPersons.Create();
     (_person.MboxSums as INotifyCollectionChanged).CollectionChanged += HandleCollectionChanged;
     _context.SaveChanges();
 }
示例#43
0
        public Receipt(IMarket market, PurchaseOrderModel purchaseOrder)
        {
            if (market == null)
                throw new ArgumentNullException("market");

            if (purchaseOrder == null)
                throw new ArgumentNullException("purchaseOrder");

            _purchaseOrder = purchaseOrder;

            _orderViewModel = new OrderViewModel(market.DefaultCurrency.Format, purchaseOrder);

            To = _orderViewModel.Email;

            var localizationService = ServiceLocator.Current.GetInstance<LocalizationService>();

            Subject = string.Format(localizationService.GetString("/common/receipt/email/subject"), _purchaseOrder.TrackingNumber);
        }
示例#44
0
 public IPriceValue GetDiscountPrice(IPriceValue price, EntryContentBase entry, Currency currency, IMarket market)
 {
     var discountedPrice = _promotionEngine.GetDiscountPrices(new[] { entry.ContentLink }, market, currency, _referenceConverter, _lineItemCalculator);
     if (discountedPrice.Any())
     {
         var highestDiscount = discountedPrice.SelectMany(x => x.DiscountPrices).OrderBy(x => x.Price).FirstOrDefault().Price;
         return new PriceValue
         {
             CatalogKey = price.CatalogKey,
             CustomerPricing = CustomerPricing.AllCustomers,
             MarketId = price.MarketId,
             MinQuantity = 1,
             UnitPrice = highestDiscount,
             ValidFrom = DateTime.UtcNow,
             ValidUntil = null
         };
     }
     return price;
 }
        //public static string GetDiscountedPrice(this List<VariationContent> variations, Price defaultPrice, IMarket market = null)
        //{
        //    // TODO: GetDiscountedPrice in find index: improvement point?? this gets the members club price in the search result as "the first variation that has a price with a pricecode"
        //    if (variations.Any())
        //    {
        //        // Has price code, but is not for customer club
        //        Func<PriceAndMarket, bool> priceFilter = d => d.PriceCode != string.Empty &&
        //                !(d.PriceTypeId == Mediachase.Commerce.Pricing.CustomerPricing.PriceType.PriceGroup.ToString() &&
        //                  d.PriceCode == Constants.CustomerGroup.CustomerClub);
        //        List<VariationContent> variationsWithPrices = variations.Where(x => x.GetPricesWithMarket(market) != null).ToList();
        //        if (variationsWithPrices.Any())
        //        {
        //            VariationContent variation = variationsWithPrices.FirstOrDefault();
        //            var price = variation.GetPricesWithMarket(market).FirstOrDefault(priceFilter);
        //            if (price != null) return price.Price;
        //            return string.Empty;
        //        }
        //    }
        //    return string.Empty;
        //}
        public static string GetCustomerClubDisplayPrice(this VariationContent variation, IMarket market = null)
        {
            if (market == null)
            {
                ICurrentMarket currentMarket = ServiceLocator.Current.GetInstance<ICurrentMarket>();
                market = currentMarket.GetCurrentMarket();
            }
            Func<PriceAndMarket, bool> priceFilter = delegate(PriceAndMarket d)
            {
                return d.PriceCode != string.Empty &&
                       (d.PriceTypeId == CustomerPricing.PriceType.PriceGroup.ToString() &&
                        d.PriceCode == Constants.CustomerGroup.CustomerClub);
            };

            var foundPrice = variation.GetPricesWithMarket(market).FirstOrDefault(priceFilter);

            if (foundPrice != null) return foundPrice.UnitPrice.ToString();
            return string.Empty;
        }
 public static int GetDefaultPriceAmount(this List<VariationContent> variations, IMarket market = null)
 {
     Price price = variations.GetDefaultPriceMoney(market);
     return price != null ? decimal.ToInt32(price.UnitPrice.Amount) : 0;
 }
 private IEnumerable<ShippingMethodViewModel> CreateShippingMethodViewModels(IMarket market, Currency currency, IShipment shipment)
 {
     var shippingRates = GetShippingRates(market, currency, shipment);
     return shippingRates.Select(r => new ShippingMethodViewModel { Id = r.Id, DisplayName = r.Name, Price = r.Money });
 }
        private IEnumerable<ShippingRate> GetShippingRates(IMarket market, Currency currency, IShipment shipment)
        {
            var methods = _shippingManagerFacade.GetShippingMethodsByMarket(market.MarketId.Value, false);
            var currentLanguage = _languageService.GetCurrentLanguage().TwoLetterISOLanguageName;

            return methods.Where(shippingMethodRow => currentLanguage.Equals(shippingMethodRow.LanguageId, StringComparison.OrdinalIgnoreCase)
                && string.Equals(currency, shippingMethodRow.Currency, StringComparison.OrdinalIgnoreCase))
                .OrderBy(shippingMethodRow => shippingMethodRow.Ordering)
                .Select(shippingMethodRow => _shippingManagerFacade.GetRate(shipment, shippingMethodRow,market));
        }
 public static PriceAndMarket GetCustomerClubPrice(this List<VariationContent> variations, IMarket market = null)
 {
     if (variations.Any())
     {
         // Find first price for customer club
         foreach (VariationContent variation in variations)
         {
             var priceAndMarket = variation.GetCustomerClubPrice(market);
             if (priceAndMarket != null)
                 return priceAndMarket;
         }
     }
     return null;
 }
 public static Price GetDefaultPrice(this VariationContent variation, IMarket market = null)
 {
     return variation.GetDefaultPriceMoney(market);
 }
        /// <summary>
        /// Gets price information for a variation as a Price object. You can get the monetary price from the UnitPrice member.
        /// </summary>
        /// <param name="variation">The variation.</param>
        /// <param name="market">The market.</param>
        /// <returns></returns>
        public static Price GetDefaultPriceMoney(this VariationContent variation, IMarket market = null)
        {
            var prices = variation.GetPrices();

            if (prices != null)
            {
                if(market != null)
                    return prices.FirstOrDefault(x => x.MarketId.Equals(market.MarketId) && x.UnitPrice.Currency == market.DefaultCurrency && x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers);
                return prices.FirstOrDefault(x => x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers);
            }
            return null;
        }
        public static Price GetDefaultPriceMoney(this List<VariationContent> variations, IMarket market = null)
        {
            if (variations.Any())
            {
                List<Price> prices = variations.Select(variant => GetDefaultPriceMoney(variant, market)).Where(x => x != null).ToList();

                if (prices.Any())
                {
                    return prices.FirstOrDefault();
                }
            }
            return null;
        }
        /// <summary>
        /// Gets the discount price, if no discount is set, returns string.Empty
        /// </summary>
        /// <param name="variation">The variation.</param>
        /// <param name="defaultPrice">The price to return if no discounted price can be found</param>
        /// <param name="market">The market.</param>
        /// <returns></returns>
        public static string GetDiscountDisplayPrice(this VariationContent variation, Price defaultPrice, IMarket market = null)
        {
            if (market == null)
            {
                ICurrentMarket currentMarket = ServiceLocator.Current.GetInstance<ICurrentMarket>();
                market = currentMarket.GetCurrentMarket();
            }
            Func<PriceAndMarket, bool> priceFilter;
            priceFilter = delegate(PriceAndMarket d)
            {
                // Find a non CustomerClub price, but still a price with a price code
                return d.PriceCode != string.Empty &&
                       !(d.PriceTypeId == CustomerPricing.PriceType.PriceGroup.ToString() &&
                         d.PriceCode == Constants.CustomerGroup.CustomerClub);
            };

            // Find a price with a price code that is not a customer club price
            var discountedPrice = variation.GetPricesWithMarket(market).FirstOrDefault(priceFilter);

            if (discountedPrice != null)
                return discountedPrice.UnitPrice.ToString();
            return string.Empty;

            //if (defaultPrice == null)
            //    return string.Empty;
            //Price price;
            //if(market == null)
            //    price = StoreHelper.GetDiscountPrice(variation.LoadEntry(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
            //else
            //    price = StoreHelper.GetDiscountPrice(variation.LoadEntry(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull),string.Empty,string.Empty,market);

            //if(price == null)
            //{
            //    return string.Empty;
            //}

            //if (price.Money == defaultPrice.Money)
            //    return string.Empty;

            //return price.Money.Amount.ToString();
        }
 /// <summary>
 /// Gets the discount price, if no discount is set, returns string.Empty
 /// </summary>
 /// <param name="variations">All variants for a product</param>
 /// <param name="defaultPrice">The price to compare against</param>
 /// <param name="market">The market.</param>
 /// <returns></returns>
 public static string GetDiscountDisplayPrice(this List<VariationContent> variations, Price defaultPrice, IMarket market = null)
 {
     if (variations.Any())
     {
         VariationContent variationContent = variations.FirstOrDefault(x => x.GetPricesWithMarket(market) != null);
         return variationContent.GetDiscountDisplayPrice(defaultPrice, market);
     }
     return string.Empty;
 }
示例#55
0
 private void UpdateProfile(IMarket market)
 {
     var profileStorage = GetProfileStorage();
     if (profileStorage != null)
     {
         var originalMarketId = profileStorage[_marketIdKey] as string;
         var currentMarketId = market == null || market.MarketId == MarketId.Default ? string.Empty : market.MarketId.Value;
         if (!string.Equals(originalMarketId, currentMarketId, StringComparison.Ordinal))
         {
             profileStorage[_marketIdKey] = currentMarketId;
             profileStorage.Save();
         }
     }
 }
示例#56
0
 public FakeCart(IMarket market, Currency currency) : base(market, currency)
 {
 }
        public static PriceAndMarket GetDiscountPrice(this VariationContent variation, IMarket market = null)
        {
            if (market == null)
            {
                ICurrentMarket currentMarket = ServiceLocator.Current.GetInstance<ICurrentMarket>();
                market = currentMarket.GetCurrentMarket();
            }
            Func<PriceAndMarket, bool> priceFilter;
            priceFilter = delegate(PriceAndMarket d)
            {
                // Find a non CustomerClub price, but still a price with a price code
                return d.PriceCode != string.Empty &&
                       !(d.PriceTypeId == CustomerPricing.PriceType.PriceGroup.ToString() &&
                         d.PriceCode == Constants.CustomerGroup.CustomerClub);
            };

            // Find a price with a price code that is not a customer club price
            var discountedPrice = variation.GetPricesWithMarket(market).FirstOrDefault(priceFilter);

            return discountedPrice;
        }
 public static PriceAndMarket GetDiscountPrice(this List<VariationContent> variations, IMarket market = null)
 {
     if (variations.Any())
     {
         VariationContent variationContent = variations.FirstOrDefault(x => x.GetPricesWithMarket(market) != null);
         return variationContent.GetDiscountPrice(market);
     }
     return null;
 }
 /// <summary>
 /// Gets the display price for the variation and market, including currency symbol.
 /// </summary>
 /// <param name="variation">The variation to retrieve price from.</param>
 /// <param name="market">The market to get price for. If null, the current market is used.</param>
 /// <returns></returns>
 public static string GetDisplayPrice(this VariationContent variation, IMarket market = null)
 {
     Price price = variation.GetDefaultPriceMoney(market);
     return price != null ? price.UnitPrice.ToString() : string.Empty;
 }
 public static string GetDisplayPrice(this List<VariationContent> variations, IMarket market = null)
 {
     if (variations.Any())
     {
         return variations.FirstOrDefault().GetDisplayPrice(market);
     }
     return null;
 }