示例#1
0
        protected Price CreateNewPrice(Sku sku, ShopWallet shop, SIN sin)
        {
            decimal modeldiscount;

            try
            {
                var eService = new EreminService();
                modeldiscount = eService.GetDiscount(sin.Character.Model, BillingHelper.GetDiscountType(sku.Nomenklatura.Specialisation.ProductType.DiscountType));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                modeldiscount = 1;
            }
            decimal discount = 1;

            if (sin.Passport.Mortgagee == sku.Corporation.Alias)
            {
                discount *= 0.9m;
            }
            discount *= modeldiscount;
            var currentScoring = sin.Scoring.CurrentFix + sin.Scoring.CurerentRelative;

            if (currentScoring == 0)
            {
                currentScoring = 1;
            }
            var price = new Price
            {
                Sku            = sku,
                Shop           = shop,
                BasePrice      = sku.Nomenklatura.BasePrice,
                CurrentScoring = currentScoring,
                DateCreated    = DateTime.Now.ToUniversalTime(),
                Discount       = discount,
                Sin            = sin,
                ShopComission  = BillingHelper.GetShopComission(shop.LifeStyle),
                ShopPrice      = BillingHelper.GetShopPrice(sku)
            };

            price.FinalPrice = BillingHelper.GetFinalPrice(price);
            Add(price);
            SaveContext();
            return(price);
        }